LCOV - code coverage report
Current view: top level - libreoffice/svx/source/svdraw - svdpntv.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 299 544 55.0 %
Date: 2012-12-17 Functions: 50 97 51.5 %
Legend: Lines: hit not hit

          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             : #include <com/sun/star/awt/XWindow.hpp>
      21             : #include <svx/svdpntv.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <svx/sdrpaintwindow.hxx>
      24             : #include <svtools/grfmgr.hxx>
      25             : #include <svx/svdmodel.hxx>
      26             : 
      27             : #ifdef DBG_UTIL
      28             : #include <svdibrow.hxx>
      29             : #endif
      30             : #include <svx/svdpage.hxx>
      31             : #include <svx/svdpagv.hxx>
      32             : #include <svl/smplhint.hxx>
      33             : 
      34             : #include <editeng/editdata.hxx>
      35             : #include <svx/svdmrkv.hxx>
      36             : #include <svx/svdundo.hxx>
      37             : #include <svx/svdview.hxx>
      38             : #include <svx/svdglue.hxx>
      39             : #include <svx/svdobj.hxx>
      40             : #include <svx/svdograf.hxx>
      41             : #include <svx/svdattrx.hxx>
      42             : #include "svdibrow.hxx"
      43             : #include "svx/svditer.hxx"
      44             : #include <svx/svdouno.hxx>
      45             : #include <svx/sdr/overlay/overlayobjectlist.hxx>
      46             : #include <svx/sdr/overlay/overlayrollingrectangle.hxx>
      47             : #include <svx/sdr/overlay/overlaymanager.hxx>
      48             : #include <svx/sxlayitm.hxx>
      49             : #include <svl/itemiter.hxx>
      50             : #include <editeng/eeitem.hxx>
      51             : #include <svl/whiter.hxx>
      52             : #include <svl/style.hxx>
      53             : #include <svx/sdrpagewindow.hxx>
      54             : #include <vcl/svapp.hxx>
      55             : #include <com/sun/star/awt/PosSize.hpp>
      56             : #include <com/sun/star/awt/XControl.hpp>
      57             : 
      58             : // #i38135#
      59             : #include <svx/sdr/contact/objectcontact.hxx>
      60             : #include <svx/sdr/animation/objectanimator.hxx>
      61             : #include <svx/sdr/contact/viewcontact.hxx>
      62             : 
      63             : using namespace ::rtl;
      64             : using namespace ::com::sun::star;
      65             : 
      66             : ////////////////////////////////////////////////////////////////////////////////////////////////////
      67             : // interface to SdrPaintWindow
      68             : 
      69        4647 : SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
      70             : {
      71        4647 :     for(SdrPaintWindowVector::const_iterator a = maPaintWindows.begin(); a != maPaintWindows.end(); ++a)
      72             :     {
      73        4647 :         if(&((*a)->GetOutputDevice()) == &rOut)
      74             :         {
      75        4647 :             return *a;
      76             :         }
      77             :     }
      78             : 
      79           0 :     return 0L;
      80             : }
      81             : 
      82        5952 : SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const
      83             : {
      84        5952 :     if(nIndex < maPaintWindows.size())
      85             :     {
      86        5952 :         return maPaintWindows[nIndex];
      87             :     }
      88             : 
      89           0 :     return 0L;
      90             : }
      91             : 
      92         538 : void SdrPaintView::AppendPaintWindow(SdrPaintWindow& rNew)
      93             : {
      94         538 :     maPaintWindows.push_back(&rNew);
      95         538 : }
      96             : 
      97          26 : SdrPaintWindow* SdrPaintView::RemovePaintWindow(SdrPaintWindow& rOld)
      98             : {
      99          26 :     SdrPaintWindow* pRetval = 0L;
     100          26 :     const SdrPaintWindowVector::iterator aFindResult = ::std::find(maPaintWindows.begin(), maPaintWindows.end(), &rOld);
     101             : 
     102          26 :     if(aFindResult != maPaintWindows.end())
     103             :     {
     104             :         // remember return value, aFindResult is no longer valid after deletion
     105          26 :         pRetval = *aFindResult;
     106          26 :         maPaintWindows.erase(aFindResult);
     107             :     }
     108             : 
     109          26 :     return pRetval;
     110             : }
     111             : 
     112           0 : OutputDevice* SdrPaintView::GetFirstOutputDevice() const
     113             : {
     114           0 :     if(PaintWindowCount())
     115             :     {
     116           0 :         return &(GetPaintWindow(0)->GetOutputDevice());
     117             :     }
     118             : 
     119           0 :     return 0L;
     120             : }
     121             : 
     122             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     123             : 
     124      198054 : TYPEINIT1( SvxViewHint, SfxHint );
     125             : 
     126        1202 : SvxViewHint::SvxViewHint (HintType eHintType)
     127        1202 :     : meHintType(eHintType)
     128             : {
     129        1202 : }
     130             : 
     131           0 : SvxViewHint::HintType SvxViewHint::GetHintType (void) const
     132             : {
     133           0 :     return meHintType;
     134             : }
     135             : 
     136             : 
     137             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     138             : 
     139           0 : TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget);
     140             : 
     141             : DBG_NAME(SdrPaintView);
     142             : 
     143        1344 : void SdrPaintView::ImpClearVars()
     144             : {
     145             : #ifdef DBG_UTIL
     146             :     pItemBrowser=NULL;
     147             : #endif
     148        1344 :     bPageVisible=sal_True;
     149        1344 :     bPageBorderVisible=sal_True;
     150        1344 :     bBordVisible=sal_True;
     151        1344 :     bGridVisible=sal_True;
     152        1344 :     bGridFront  =sal_False;
     153        1344 :     bHlplVisible=sal_True;
     154        1344 :     bHlplFront  =sal_True;
     155        1344 :     bGlueVisible=sal_False;
     156        1344 :     bGlueVisible2=sal_False;
     157        1344 :     bGlueVisible3=sal_False;
     158        1344 :     bGlueVisible4=sal_False;
     159        1344 :     bSwapAsynchron=sal_False;
     160        1344 :     bPrintPreview=sal_False;
     161        1344 :     mbPreviewRenderer=sal_False;
     162             : 
     163        1344 :     eAnimationMode = SDR_ANIMATION_ANIMATE;
     164        1344 :     bAnimationPause = sal_False;
     165             : 
     166        1344 :     nHitTolPix=2;
     167        1344 :     nMinMovPix=3;
     168        1344 :     nHitTolLog=0;
     169        1344 :     nMinMovLog=0;
     170        1344 :     pActualOutDev=NULL;
     171        1344 :     pDragWin=NULL;
     172        1344 :     bRestoreColors=sal_True;
     173        1344 :     pDefaultStyleSheet=NULL;
     174        1344 :     bSomeObjChgdFlag=sal_False;
     175        1344 :     nGraphicManagerDrawMode = GRFMGR_DRAW_STANDARD;
     176        1344 :     aComeBackTimer.SetTimeout(1);
     177        1344 :     aComeBackTimer.SetTimeoutHdl(LINK(this,SdrPaintView,ImpComeBackHdl));
     178        1344 :     String aNam;    // System::GetUserName() just return an empty string
     179             : 
     180        1344 :     if (pMod)
     181        1344 :         SetDefaultStyleSheet(pMod->GetDefaultStyleSheet(), sal_True);
     182             : 
     183        1344 :     aNam.ToUpperAscii();
     184             : 
     185        1344 :     maGridColor = Color( COL_BLACK );
     186        1344 : }
     187             : 
     188        1344 : SdrPaintView::SdrPaintView(SdrModel* pModel1, OutputDevice* pOut)
     189             : :   mpPageView(NULL),
     190        1344 :     aDefaultAttr(pModel1->GetItemPool()),
     191             :     mbBufferedOutputAllowed(false),
     192             :     mbBufferedOverlayAllowed(false),
     193             :     mbPagePaintingAllowed(true),
     194             :     mbHideOle(false),
     195             :     mbHideChart(false),
     196             :     mbHideDraw(false),
     197        2688 :     mbHideFormControl(false)
     198             : {
     199             :     DBG_CTOR(SdrPaintView,NULL);
     200        1344 :     pMod=pModel1;
     201        1344 :     ImpClearVars();
     202             : 
     203        1344 :     if(pOut)
     204             :     {
     205         538 :         AddWindowToPaintView(pOut);
     206             :     }
     207             : 
     208             :     // flag to visualize groups
     209        1344 :     bVisualizeEnteredGroup = sal_True;
     210             : 
     211        1344 :     maColorConfig.AddListener(this);
     212        1344 :     onChangeColorConfig();
     213        1344 : }
     214             : 
     215        1016 : SdrPaintView::~SdrPaintView()
     216             : {
     217             :     DBG_DTOR(SdrPaintView,NULL);
     218         508 :     if (pDefaultStyleSheet)
     219         132 :         EndListening(*pDefaultStyleSheet);
     220             : 
     221         508 :     maColorConfig.RemoveListener(this);
     222         508 :     ClearPageView();
     223             : 
     224             : #ifdef DBG_UTIL
     225             :     if(pItemBrowser)
     226             :     {
     227             :         delete pItemBrowser;
     228             :     }
     229             : #endif
     230             : 
     231             :     // delete existing SdrPaintWindows
     232        1118 :     while(!maPaintWindows.empty())
     233             :     {
     234         102 :         delete maPaintWindows.back();
     235         102 :         maPaintWindows.pop_back();
     236             :     }
     237         508 : }
     238             : 
     239             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     240             : 
     241       31137 : void SdrPaintView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
     242             : {
     243             :     //If the stylesheet has been destroyed
     244       31137 :     if (&rBC == pDefaultStyleSheet)
     245             :     {
     246         792 :         if (rHint.ISA(SfxSimpleHint) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
     247           0 :             pDefaultStyleSheet = NULL;
     248       31929 :         return;
     249             :     }
     250             : 
     251       30345 :     sal_Bool bObjChg=!bSomeObjChgdFlag; // if sal_True, evaluate for ComeBack timer
     252       30345 :     if (bObjChg) {
     253        2739 :         SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
     254        2739 :         if (pSdrHint!=NULL) {
     255        2129 :             SdrHintKind eKind=pSdrHint->GetKind();
     256        2129 :             if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED) {
     257         772 :                 if (bObjChg) {
     258         772 :                     bSomeObjChgdFlag=sal_True;
     259         772 :                     aComeBackTimer.Start();
     260             :                 }
     261             :             }
     262        2129 :             if (eKind==HINT_PAGEORDERCHG) {
     263        1264 :                 const SdrPage* pPg=pSdrHint->GetPage();
     264             : 
     265        1264 :                 if(pPg && !pPg->IsInserted())
     266             :                 {
     267         168 :                     if(mpPageView && mpPageView->GetPage() == pPg)
     268             :                     {
     269           0 :                         HideSdrPage();
     270             :                     }
     271             :                 }
     272             :             }
     273             :         }
     274             :     }
     275             : }
     276             : 
     277           0 : void SdrPaintView::ConfigurationChanged( ::utl::ConfigurationBroadcaster* , sal_uInt32 )
     278             : {
     279           0 :     onChangeColorConfig();
     280           0 :     InvalidateAllWin();
     281           0 : }
     282             : 
     283             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     284             : 
     285         408 : IMPL_LINK_NOARG_INLINE_START(SdrPaintView, ImpComeBackHdl)
     286             : {
     287         408 :     if (bSomeObjChgdFlag) {
     288         408 :         bSomeObjChgdFlag=sal_False;
     289         408 :         ModelHasChanged();
     290             :     }
     291         408 :     return 0;
     292             : }
     293         277 : IMPL_LINK_NOARG_INLINE_END(SdrPaintView,ImpComeBackHdl)
     294             : 
     295         131 : void SdrPaintView::FlushComeBackTimer() const
     296             : {
     297         131 :     if (bSomeObjChgdFlag) {
     298             :         // casting to nonconst
     299         131 :         ((SdrPaintView*)this)->ImpComeBackHdl(&((SdrPaintView*)this)->aComeBackTimer);
     300         131 :         ((SdrPaintView*)this)->aComeBackTimer.Stop();
     301             :     }
     302         131 : }
     303             : 
     304         408 : void SdrPaintView::ModelHasChanged()
     305             : {
     306             :     // broadcast to all PageViews
     307         408 :     if(mpPageView && !mpPageView->GetPage()->IsInserted())
     308             :     {
     309           0 :         HideSdrPage();
     310             :     }
     311             : 
     312             :     // test mpPageView here again, HideSdrPage() may have invalidated it.
     313         408 :     if(mpPageView)
     314             :     {
     315         165 :         mpPageView->ModelHasChanged();
     316             :     }
     317             : 
     318             : #ifdef DBG_UTIL
     319             :     if(pItemBrowser)
     320             :     {
     321             :         pItemBrowser->SetDirty();
     322             :     }
     323             : #endif
     324         408 : }
     325             : 
     326             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     327             : 
     328          60 : sal_Bool SdrPaintView::IsAction() const
     329             : {
     330          60 :     return false;
     331             : }
     332             : 
     333           0 : void SdrPaintView::MovAction(const Point&)
     334             : {
     335           0 : }
     336             : 
     337           0 : void SdrPaintView::EndAction()
     338             : {
     339           0 : }
     340             : 
     341           0 : void SdrPaintView::BckAction()
     342             : {
     343           0 : }
     344             : 
     345         692 : void SdrPaintView::BrkAction()
     346             : {
     347         692 : }
     348             : 
     349           0 : void SdrPaintView::TakeActionRect(Rectangle&) const
     350             : {
     351           0 : }
     352             : 
     353             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     354             : // info about TextEdit. Default is sal_False.
     355           0 : bool SdrPaintView::IsTextEdit() const
     356             : {
     357           0 :     return false;
     358             : }
     359             : 
     360             : // info about TextEditPageView. Default is 0L.
     361           0 : SdrPageView* SdrPaintView::GetTextEditPageView() const
     362             : {
     363           0 :     return 0L;
     364             : }
     365             : 
     366             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     367             : 
     368           0 : sal_uInt16 SdrPaintView::ImpGetMinMovLogic(short nMinMov, const OutputDevice* pOut) const
     369             : {
     370           0 :     if (nMinMov>=0) return sal_uInt16(nMinMov);
     371           0 :     if (pOut==NULL)
     372             :     {
     373           0 :         pOut = GetFirstOutputDevice();
     374             :     }
     375           0 :     if (pOut!=NULL) {
     376           0 :         return short(-pOut->PixelToLogic(Size(nMinMov,0)).Width());
     377             :     } else {
     378           0 :         return 0;
     379             :     }
     380             : }
     381             : 
     382           0 : sal_uInt16 SdrPaintView::ImpGetHitTolLogic(short nHitTol, const OutputDevice* pOut) const
     383             : {
     384           0 :     if (nHitTol>=0) return sal_uInt16(nHitTol);
     385           0 :     if (pOut==NULL)
     386             :     {
     387           0 :         pOut = GetFirstOutputDevice();
     388             :     }
     389           0 :     if (pOut!=NULL) {
     390           0 :         return short(-pOut->PixelToLogic(Size(nHitTol,0)).Width());
     391             :     } else {
     392           0 :         return 0;
     393             :     }
     394             : }
     395             : 
     396        2547 : void SdrPaintView::TheresNewMapMode()
     397             : {
     398        2547 :     if (pActualOutDev!=NULL) {
     399        2005 :         nHitTolLog=(sal_uInt16)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nHitTolPix,0)).Width();
     400        2005 :         nMinMovLog=(sal_uInt16)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nMinMovPix,0)).Width();
     401             :     }
     402        2547 : }
     403             : 
     404        1120 : void SdrPaintView::SetActualWin(const OutputDevice* pWin)
     405             : {
     406        1120 :     pActualOutDev=pWin;
     407        1120 :     TheresNewMapMode();
     408        1120 : }
     409             : 
     410             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     411             : 
     412         508 : void SdrPaintView::ClearPageView()
     413             : {
     414         508 :     BrkAction();
     415             : 
     416         508 :     if(mpPageView)
     417             :     {
     418          24 :         InvalidateAllWin();
     419          24 :         delete mpPageView;
     420          24 :         mpPageView = 0L;
     421             :     }
     422         508 : }
     423             : 
     424         574 : SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage)
     425             : {
     426         574 :     if(pPage && (!mpPageView || mpPageView->GetPage() != pPage))
     427             :     {
     428         574 :         if(mpPageView)
     429             :         {
     430           0 :             InvalidateAllWin();
     431           0 :             delete mpPageView;
     432             :         }
     433             : 
     434         574 :         mpPageView = new SdrPageView(pPage, *((SdrView*)this));
     435         574 :         mpPageView->Show();
     436             :     }
     437             : 
     438         574 :     return mpPageView;
     439             : }
     440             : 
     441         142 : void SdrPaintView::HideSdrPage()
     442             : {
     443         142 :     if(mpPageView)
     444             :     {
     445         140 :         mpPageView->Hide();
     446         140 :         delete mpPageView;
     447         140 :         mpPageView = 0L;
     448             :     }
     449         142 : }
     450             : 
     451         538 : void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin)
     452             : {
     453             :     DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)");
     454         538 :     SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin);
     455         538 :     AppendPaintWindow(*pNewPaintWindow);
     456             : 
     457         538 :     if(mpPageView)
     458             :     {
     459           0 :         mpPageView->AddPaintWindowToPageView(*pNewPaintWindow);
     460             :     }
     461             : 
     462             : #ifdef DBG_UTIL
     463             :     if (pItemBrowser!=NULL)
     464             :         pItemBrowser->ForceParent();
     465             : #endif
     466         538 : }
     467             : 
     468          26 : void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
     469             : {
     470             :     DBG_ASSERT(pOldWin, "SdrPaintView::DeleteWindowFromPaintView: No OutputDevice(!)");
     471          26 :     SdrPaintWindow* pCandidate = FindPaintWindow(*pOldWin);
     472             : 
     473          26 :     if(pCandidate)
     474             :     {
     475          26 :         if(mpPageView)
     476             :         {
     477          26 :             mpPageView->RemovePaintWindowFromPageView(*pCandidate);
     478             :         }
     479             : 
     480          26 :         RemovePaintWindow(*pCandidate);
     481          26 :         delete pCandidate;
     482             :     }
     483             : 
     484             : #ifdef DBG_UTIL
     485             :     if (pItemBrowser!=NULL)
     486             :         pItemBrowser->ForceParent();
     487             : #endif
     488          26 : }
     489             : 
     490          68 : void SdrPaintView::SetLayerVisible(const XubString& rName, sal_Bool bShow)
     491             : {
     492          68 :     if(mpPageView)
     493             :     {
     494          68 :         mpPageView->SetLayerVisible(rName,bShow);
     495             :     }
     496             : 
     497          68 :     InvalidateAllWin();
     498          68 : }
     499             : 
     500           0 : bool SdrPaintView::IsLayerVisible(const XubString& rName) const
     501             : {
     502           0 :     if(mpPageView)
     503             :     {
     504           0 :         return mpPageView->IsLayerVisible(rName);
     505             :     }
     506             : 
     507           0 :     return false;
     508             : }
     509             : 
     510         340 : void SdrPaintView::SetLayerLocked(const XubString& rName, sal_Bool bLock)
     511             : {
     512         340 :     if(mpPageView)
     513             :     {
     514         340 :         mpPageView->SetLayerLocked(rName,bLock);
     515             :     }
     516         340 : }
     517             : 
     518           0 : bool SdrPaintView::IsLayerLocked(const XubString& rName) const
     519             : {
     520           0 :     if(mpPageView)
     521             :     {
     522           0 :         return mpPageView->IsLayerLocked(rName);
     523             :     }
     524             : 
     525           0 :     return false;
     526             : }
     527             : 
     528           4 : void SdrPaintView::SetLayerPrintable(const XubString& rName, sal_Bool bPrn)
     529             : {
     530           4 :     if(mpPageView)
     531             :     {
     532           4 :         mpPageView->SetLayerPrintable(rName,bPrn);
     533             :     }
     534           4 : }
     535             : 
     536           0 : bool SdrPaintView::IsLayerPrintable(const XubString& rName) const
     537             : {
     538           0 :     if(mpPageView)
     539             :     {
     540           0 :         return mpPageView->IsLayerPrintable(rName);
     541             :     }
     542             : 
     543           0 :     return false;
     544             : }
     545             : 
     546        2358 : void SdrPaintView::PrePaint()
     547             : {
     548        2358 :     if(mpPageView)
     549             :     {
     550        2358 :         mpPageView->PrePaint();
     551             :     }
     552        2358 : }
     553             : 
     554             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     555             : // #define SVX_REPAINT_TIMER_TEST
     556             : 
     557           0 : void SdrPaintView::CompleteRedraw(OutputDevice* pOut, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
     558             : {
     559             : #ifdef SVX_REPAINT_TIMER_TEST
     560             : #define REMEMBERED_TIMES_COUNT  (10)
     561             :     static bool bDoTimerTest(false);
     562             :     static bool bTimesInited(false);
     563             :     static sal_uInt32 nRepeatCount(10L);
     564             :     static double fLastTimes[REMEMBERED_TIMES_COUNT];
     565             :     const sal_uInt32 nStartTime(Time::GetSystemTicks());
     566             :     sal_uInt32 count(1L);
     567             :     sal_uInt32 a;
     568             : 
     569             :     if(bDoTimerTest)
     570             :     {
     571             :         count = nRepeatCount;
     572             :     }
     573             : 
     574             :     for(a = 0L; a < count; a++)
     575             :     {
     576             : #endif // SVX_REPAINT_TIMER_TEST
     577             : 
     578             :     // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
     579             :     // rReg may be made more granular (fine) with using it. Normally, rReg
     580             :     // does come from Window::Paint() anyways and thus is based on a single
     581             :     // rectangle which was derived from exactly that repaint region
     582           0 :     Region aOptimizedRepaintRegion(rReg);
     583             : 
     584           0 :     if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType())
     585             :     {
     586           0 :         Window* pWindow = (Window*)pOut;
     587             : 
     588           0 :         if(pWindow->IsInPaint())
     589             :         {
     590           0 :             if(!pWindow->GetPaintRegion().IsEmpty())
     591             :             {
     592           0 :                 aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
     593             : 
     594             : #ifdef DBG_UTIL
     595             :                 // #i74769# test-paint repaint region
     596             :                 static bool bDoPaintForVisualControl(false);
     597             :                 if(bDoPaintForVisualControl)
     598             :                 {
     599             :                     RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
     600             :                     Rectangle aRegionRectangle;
     601             : 
     602             :                     while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
     603             :                     {
     604             :                         pWindow->SetLineColor(COL_LIGHTGREEN);
     605             :                         pWindow->SetFillColor();
     606             :                         pWindow->DrawRect(aRegionRectangle);
     607             :                     }
     608             : 
     609             :                     aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
     610             :                 }
     611             : #endif
     612             :             }
     613             :         }
     614             :     }
     615             : 
     616           0 :     SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
     617             :     OSL_ENSURE(pPaintWindow, "SdrPaintView::CompleteRedraw: No OutDev (!)");
     618             : 
     619           0 :     DoCompleteRedraw(*pPaintWindow, aOptimizedRepaintRegion, pRedirector);
     620           0 :     EndCompleteRedraw(*pPaintWindow, true);
     621             : 
     622             : #ifdef SVX_REPAINT_TIMER_TEST
     623             :     }
     624             : 
     625             :     if(bDoTimerTest)
     626             :     {
     627             :         const sal_uInt32 nStopTime(Time::GetSystemTicks());
     628             :         const sal_uInt32 nNeededTime(nStopTime - nStartTime);
     629             :         const double fTimePerPaint((double)nNeededTime / (double)nRepeatCount);
     630             : 
     631             :         if(!bTimesInited)
     632             :         {
     633             :             for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
     634             :             {
     635             :                 fLastTimes[a] = fTimePerPaint;
     636             :             }
     637             : 
     638             :             bTimesInited = true;
     639             :         }
     640             :         else
     641             :         {
     642             :             for(a = 1L; a < REMEMBERED_TIMES_COUNT; a++)
     643             :             {
     644             :                 fLastTimes[a - 1L] = fLastTimes[a];
     645             :             }
     646             : 
     647             :             fLastTimes[REMEMBERED_TIMES_COUNT - 1L] = fTimePerPaint;
     648             :         }
     649             : 
     650             :         double fAddedTimes(0.0);
     651             : 
     652             :         for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
     653             :         {
     654             :             fAddedTimes += fLastTimes[a];
     655             :         }
     656             : 
     657             :         const double fAverageTimePerPaint(fAddedTimes / (double)REMEMBERED_TIMES_COUNT);
     658             : 
     659             :         fprintf(stderr, "-----------(start result)----------\n");
     660             :         fprintf(stderr, "StartTime : %u, StopTime: %u, NeededTime: %u, TimePerPaint: %f\n", nStartTime, nStopTime, nNeededTime, fTimePerPaint);
     661             :         fprintf(stderr, "Remembered times: ");
     662             : 
     663             :         for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
     664             :         {
     665             :             fprintf(stderr, "%d: %f ", a, fLastTimes[a]);
     666             :         }
     667             : 
     668             :         fprintf(stderr, "\n");
     669             :         fprintf(stderr, "AverageTimePerPaint: %f\n", fAverageTimePerPaint);
     670             :         fprintf(stderr, "-----------(stop result)----------\n");
     671             :     }
     672             : #endif // SVX_REPAINT_TIMER_TEST
     673           0 : }
     674             : 
     675             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     676             : // #i72889#
     677             : 
     678         695 : SdrPaintWindow* SdrPaintView::BeginCompleteRedraw(OutputDevice* pOut)
     679             : {
     680             :     OSL_ENSURE(pOut, "SdrPaintView::BeginCompleteRedraw: No OutDev (!)");
     681         695 :     SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
     682             : 
     683         695 :     if(pPaintWindow)
     684             :     {
     685             :         // draw preprocessing, only for known devices
     686             :         // prepare PreRendering
     687         695 :         pPaintWindow->PreparePreRenderDevice();
     688             :     }
     689             :     else
     690             :     {
     691             :         // None of the known OutputDevices is the target of this paint, use
     692             :         // a temporary SdrPaintWindow for this Redraw.
     693           0 :         pPaintWindow = new SdrPaintWindow(*this, *pOut);
     694           0 :         pPaintWindow->setTemporaryTarget(true);
     695             :     }
     696             : 
     697         695 :     return pPaintWindow;
     698             : }
     699             : 
     700           0 : void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
     701             : {
     702             :     // redraw all PageViews with the target. This may expand the RedrawRegion
     703             :     // at the PaintWindow, plus taking care of FormLayer expansion
     704           0 :     if(mpPageView)
     705             :     {
     706           0 :         mpPageView->CompleteRedraw(rPaintWindow, rReg, pRedirector);
     707             :     }
     708           0 : }
     709             : 
     710         695 : void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
     711             : {
     712         695 :     if(rPaintWindow.getTemporaryTarget())
     713             :     {
     714             :         // get rid of temp target again
     715           0 :         delete (&rPaintWindow);
     716             :     }
     717             :     else
     718             :     {
     719             :         // draw postprocessing, only for known devices
     720             :         // it is necessary to always paint FormLayer
     721         695 :         if(bPaintFormLayer)
     722             :         {
     723         695 :             ImpFormLayerDrawing(rPaintWindow);
     724             :         }
     725             : 
     726             :         // look for active TextEdit. As long as this cannot be painted to a VDev,
     727             :         // it cannot get part of buffering. In that case, output evtl. prerender
     728             :         // early and paint text edit to window.
     729         695 :         const bool bTextEditActive(IsTextEdit() && GetTextEditPageView());
     730             : 
     731         695 :         if(bTextEditActive)
     732             :         {
     733             :             // output PreRendering and destroy it so that it is not used for FormLayer
     734             :             // or overlay
     735           0 :             rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
     736             : 
     737             :             // draw old text edit stuff before overlay to have it as part of the background
     738             :             // ATM. This will be changed to have the text editing on the overlay, bit it
     739             :             // is not an easy thing to do, see BegTextEdit and the OutlinerView stuff used...
     740           0 :             if(bTextEditActive)
     741             :             {
     742           0 :                 ImpTextEditDrawing(rPaintWindow);
     743             :             }
     744             : 
     745             :             // draw Overlay directly to window. This will save the contents of the window
     746             :             // in the RedrawRegion to the overlay background buffer, too.
     747             :             // This may lead to problems when reading from the screen is slow from the
     748             :             // graphics driver/graphiccard combination.
     749           0 :             rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), false);
     750             :         }
     751             :         else
     752             :         {
     753             :             // draw Overlay, also to PreRender device if exists
     754         695 :             rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), true);
     755             : 
     756             :             // output PreRendering
     757         695 :             rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
     758             :         }
     759             :     }
     760         695 : }
     761             : 
     762             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     763             : 
     764         695 : SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
     765             : {
     766             :     // #i74769# use BeginCompleteRedraw() as common base
     767         695 :     SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
     768             :     OSL_ENSURE(pPaintWindow, "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)");
     769             : 
     770         695 :     if(mpPageView)
     771             :     {
     772         695 :         SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow);
     773             : 
     774         695 :         if(pKnownTarget)
     775             :         {
     776         695 :             Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect );
     777             : 
     778             :             // prepare redraw
     779         695 :             pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion);
     780             : 
     781             :             // remember prepared SdrPageWindow
     782         695 :             mpPageView->setPreparedPageWindow(pKnownTarget);
     783             :         }
     784             :     }
     785             : 
     786         695 :     return pPaintWindow;
     787             : }
     788             : 
     789         695 : void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
     790             : {
     791             :     // #i74769# use EndCompleteRedraw() as common base
     792         695 :     EndCompleteRedraw(rPaintWindow, bPaintFormLayer);
     793             : 
     794         695 :     if(mpPageView)
     795             :     {
     796             :         // forget prepared SdrPageWindow
     797         695 :         mpPageView->setPreparedPageWindow(0);
     798             :     }
     799         695 : }
     800             : 
     801        3926 : void SdrPaintView::UpdateDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
     802             : {
     803        3926 :     SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
     804             :     OSL_ENSURE(pPaintWindow, "SdrPaintView::UpdateDrawLayersRegion: No SdrPaintWindow (!)");
     805             : 
     806        3926 :     if(mpPageView)
     807             :     {
     808        3926 :         SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow);
     809             : 
     810        3926 :         if(pKnownTarget)
     811             :         {
     812        3926 :             Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect );
     813        3926 :             pKnownTarget->GetPaintWindow().SetRedrawRegion(aOptimizedRepaintRegion);
     814        3926 :             mpPageView->setPreparedPageWindow(pKnownTarget); // already set actually
     815             :         }
     816             :     }
     817        3926 : }
     818             : 
     819        4621 : Region SdrPaintView::OptimizeDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
     820             : {
     821             :     // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
     822             :     // rReg may be made more granular (fine) with using it. Normally, rReg
     823             :     // does come from Window::Paint() anyways and thus is based on a single
     824             :     // rectangle which was derived from exactly that repaint region
     825        4621 :     Region aOptimizedRepaintRegion(rReg);
     826             : 
     827             :     // #i76114# Intersecting the region with the Window's paint region is disabled
     828             :     // for print preview in Calc, because the intersection can be empty (if the paint
     829             :     // region is outside of the table area of the page), and then no clip region
     830             :     // would be set.
     831        4621 :     if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect)
     832             :     {
     833        4615 :         Window* pWindow = (Window*)pOut;
     834             : 
     835        4615 :         if(pWindow->IsInPaint())
     836             :         {
     837        4247 :             if(!pWindow->GetPaintRegion().IsEmpty())
     838             :             {
     839        4247 :                 aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
     840             : 
     841             : #ifdef DBG_UTIL
     842             :                 // #i74769# test-paint repaint region
     843             :                 static bool bDoPaintForVisualControl(false);
     844             :                 if(bDoPaintForVisualControl)
     845             :                 {
     846             :                     RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
     847             :                     Rectangle aRegionRectangle;
     848             : 
     849             :                     while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
     850             :                     {
     851             :                         pWindow->SetLineColor(COL_LIGHTGREEN);
     852             :                         pWindow->SetFillColor();
     853             :                         pWindow->DrawRect(aRegionRectangle);
     854             :                     }
     855             : 
     856             :                     aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
     857             :                 }
     858             : #endif
     859             :             }
     860             :         }
     861             :     }
     862        4621 :     return aOptimizedRepaintRegion;
     863             : }
     864             : 
     865             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     866             : 
     867           0 : void SdrPaintView::ImpTextEditDrawing(SdrPaintWindow& rPaintWindow) const
     868             : {
     869             :     // draw old text edit stuff
     870           0 :     if(IsTextEdit())
     871             :     {
     872           0 :         SdrPageView* pPageView = GetTextEditPageView();
     873             : 
     874           0 :         if(pPageView)
     875             :         {
     876             :             // paint TextEdit directly to the destination OutDev
     877           0 :             const Region& rRedrawRegion = rPaintWindow.GetRedrawRegion();
     878           0 :             const Rectangle aCheckRect(rRedrawRegion.GetBoundRect());
     879           0 :             pPageView->PaintOutlinerView(&rPaintWindow.GetOutputDevice(), aCheckRect);
     880             :         }
     881             :     }
     882           0 : }
     883             : 
     884         695 : void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const
     885             : {
     886         695 :     if(mpPageView)
     887             :     {
     888         695 :         SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow);
     889             : 
     890         695 :         if(pKnownTarget)
     891             :         {
     892         695 :             const SdrModel& rModel = *(GetModel());
     893         695 :             const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
     894         695 :             const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
     895             : 
     896             :             // BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too
     897             :             // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact
     898         695 :             mpPageView->setPreparedPageWindow(pKnownTarget);
     899         695 :             mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice());
     900         695 :             mpPageView->setPreparedPageWindow(0);
     901             :         }
     902             :     }
     903         695 : }
     904             : 
     905             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     906             : 
     907           0 : sal_Bool SdrPaintView::KeyInput(const KeyEvent& /*rKEvt*/, Window* /*pWin*/)
     908             : {
     909           0 :     return sal_False;
     910             : }
     911             : 
     912           0 : void SdrPaintView::GlueInvalidate() const
     913             : {
     914           0 :     const sal_uInt32 nWindowCount(PaintWindowCount());
     915             : 
     916           0 :     for(sal_uInt32 nWinNum(0L); nWinNum < nWindowCount; nWinNum++)
     917             :     {
     918           0 :         SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum);
     919             : 
     920           0 :         if(pPaintWindow->OutputToWindow())
     921             :         {
     922           0 :             OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     923             : 
     924           0 :             if(mpPageView)
     925             :             {
     926           0 :                 const SdrObjList* pOL=mpPageView->GetObjList();
     927           0 :                 sal_uIntPtr nObjAnz=pOL->GetObjCount();
     928           0 :                 for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
     929           0 :                     const SdrObject* pObj=pOL->GetObj(nObjNum);
     930           0 :                     const SdrGluePointList* pGPL=pObj->GetGluePointList();
     931           0 :                     if (pGPL!=NULL && pGPL->GetCount()!=0) {
     932           0 :                         pGPL->Invalidate((Window&)rOutDev, pObj);
     933             :                     }
     934             :                 }
     935             :             }
     936             :         }
     937             :     }
     938           0 : }
     939             : 
     940        2616 : void SdrPaintView::InvalidateAllWin()
     941             : {
     942        2616 :     const sal_uInt32 nWindowCount(PaintWindowCount());
     943             : 
     944        5164 :     for(sal_uInt32 a(0L); a < nWindowCount; a++)
     945             :     {
     946        2548 :         SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
     947             : 
     948        2548 :         if(pPaintWindow->OutputToWindow())
     949             :         {
     950        2504 :             InvalidateOneWin((Window&)pPaintWindow->GetOutputDevice());
     951             :         }
     952             :     }
     953        2616 : }
     954             : 
     955        2228 : void SdrPaintView::InvalidateAllWin(const Rectangle& rRect, sal_Bool bPlus1Pix)
     956             : {
     957        2228 :     const sal_uInt32 nWindowCount(PaintWindowCount());
     958             : 
     959        4430 :     for(sal_uInt32 a(0L); a < nWindowCount; a++)
     960             :     {
     961        2202 :         SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
     962             : 
     963        2202 :         if(pPaintWindow->OutputToWindow())
     964             :         {
     965        2158 :             OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     966        2158 :             Rectangle aRect(rRect);
     967             : 
     968        2158 :             if(bPlus1Pix)
     969             :             {
     970           0 :                 Size aPixSiz(1,1);
     971           0 :                 Size aSiz(rOutDev.PixelToLogic(aPixSiz));
     972           0 :                 aRect.Left  ()-=aSiz.Width();
     973           0 :                 aRect.Top   ()-=aSiz.Height();
     974           0 :                 aRect.Right ()+=aSiz.Width();
     975           0 :                 aRect.Bottom()+=aSiz.Height();
     976             :             }
     977             : 
     978        2158 :             Point aOrg(rOutDev.GetMapMode().GetOrigin());
     979        2158 :             aOrg.X()=-aOrg.X(); aOrg.Y()=-aOrg.Y();
     980        2158 :             Rectangle aOutRect(aOrg, rOutDev.GetOutputSize());
     981             : 
     982        2158 :             if (aRect.IsOver(aOutRect))
     983             :             {
     984         170 :                 InvalidateOneWin((Window&)rOutDev, aRect);
     985             :             }
     986             :         }
     987             :     }
     988        2228 : }
     989             : 
     990        2504 : void SdrPaintView::InvalidateOneWin(Window& rWin)
     991             : {
     992             :     // do not erase background, that causes flicker (!)
     993        2504 :     rWin.Invalidate(INVALIDATE_NOERASE);
     994        2504 : }
     995             : 
     996         170 : void SdrPaintView::InvalidateOneWin(Window& rWin, const Rectangle& rRect)
     997             : {
     998             :     // do not erase background, that causes flicker (!)
     999         170 :     rWin.Invalidate(rRect, INVALIDATE_NOERASE);
    1000         170 : }
    1001             : 
    1002           0 : void SdrPaintView::LeaveOneGroup()
    1003             : {
    1004           0 :     if(mpPageView)
    1005             :     {
    1006           0 :         mpPageView->LeaveOneGroup();
    1007             :     }
    1008           0 : }
    1009             : 
    1010           0 : void SdrPaintView::LeaveAllGroup()
    1011             : {
    1012           0 :     if(mpPageView)
    1013             :     {
    1014           0 :         mpPageView->LeaveAllGroup();
    1015             :     }
    1016           0 : }
    1017             : 
    1018           0 : bool SdrPaintView::IsGroupEntered() const
    1019             : {
    1020           0 :     if(mpPageView)
    1021             :     {
    1022           0 :         return (mpPageView->GetEnteredLevel() != 0);
    1023             :     }
    1024             : 
    1025           0 :     return false;
    1026             : }
    1027             : 
    1028           0 : void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr, sal_Bool /*bReplaceAll*/)
    1029             : {
    1030             :     // bReplaceAll has no effect here at all.
    1031           0 :     sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
    1032           0 :     const SfxPoolItem *pPoolItem=NULL;
    1033           0 :     if (rAttr.GetItemState(SDRATTR_LAYERID,sal_True,&pPoolItem)==SFX_ITEM_SET) {
    1034           0 :         SdrLayerID nLayerId=((const SdrLayerIdItem*)pPoolItem)->GetValue();
    1035           0 :         const SdrLayer* pLayer=pMod->GetLayerAdmin().GetLayerPerID(nLayerId);
    1036           0 :         if (pLayer!=NULL) {
    1037           0 :             if (bMeasure) aMeasureLayer=pLayer->GetName();
    1038           0 :             else aAktLayer=pLayer->GetName();
    1039             :         }
    1040             :     }
    1041           0 :     if (rAttr.GetItemState(SDRATTR_LAYERNAME,sal_True,&pPoolItem)==SFX_ITEM_SET) {
    1042           0 :         if (bMeasure) aMeasureLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
    1043           0 :         else aAktLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
    1044             :     }
    1045           0 : }
    1046             : 
    1047           0 : void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr, sal_Bool /*bOnlyHardAttr*/) const
    1048             : {
    1049             :     // bOnlyHardAttr has no effect here at all.
    1050           0 :     sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
    1051           0 :     const XubString& aNam=bMeasure?aMeasureLayer:aAktLayer;
    1052           0 :     rAttr.Put(SdrLayerNameItem(aNam));
    1053           0 :     SdrLayerID nLayer=pMod->GetLayerAdmin().GetLayerID(aNam,sal_True);
    1054           0 :     if (nLayer!=SDRLAYER_NOTFOUND) {
    1055           0 :         rAttr.Put(SdrLayerIdItem(nLayer));
    1056             :     }
    1057           0 : }
    1058             : 
    1059           0 : void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, sal_Bool bReplaceAll)
    1060             : {
    1061             : #ifdef DBG_UTIL
    1062             :     {
    1063             :         sal_Bool bHasEEFeatureItems=sal_False;
    1064             :         SfxItemIter aIter(rAttr);
    1065             :         const SfxPoolItem* pItem=aIter.FirstItem();
    1066             :         while (!bHasEEFeatureItems && pItem!=NULL) {
    1067             :             if (!IsInvalidItem(pItem)) {
    1068             :                 sal_uInt16 nW=pItem->Which();
    1069             :                 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=sal_True;
    1070             :             }
    1071             :             pItem=aIter.NextItem();
    1072             :         }
    1073             : 
    1074             :         if(bHasEEFeatureItems)
    1075             :         {
    1076             :             String aMessage;
    1077             :             aMessage.AppendAscii("SdrPaintView::SetDefaultAttr(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents.");
    1078             :             InfoBox(NULL, aMessage).Execute();
    1079             :         }
    1080             :     }
    1081             : #endif
    1082           0 :     if (bReplaceAll) aDefaultAttr.Set(rAttr);
    1083           0 :     else aDefaultAttr.Put(rAttr,sal_False); // if FALSE, regard InvalidItems as "holes," not as Default
    1084           0 :     SetNotPersistDefaultAttr(rAttr,bReplaceAll);
    1085             : #ifdef DBG_UTIL
    1086             :     if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
    1087             : #endif
    1088           0 : }
    1089             : 
    1090        1344 : void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
    1091             : {
    1092        1344 :     if (pDefaultStyleSheet)
    1093           0 :         EndListening(*pDefaultStyleSheet);
    1094        1344 :     pDefaultStyleSheet=pStyleSheet;
    1095        1344 :     if (pDefaultStyleSheet)
    1096         142 :         StartListening(*pDefaultStyleSheet);
    1097             : 
    1098        1344 :     if (pStyleSheet!=NULL && !bDontRemoveHardAttr) {
    1099           0 :         SfxWhichIter aIter(pStyleSheet->GetItemSet());
    1100           0 :         sal_uInt16 nWhich=aIter.FirstWhich();
    1101           0 :         while (nWhich!=0) {
    1102           0 :             if (pStyleSheet->GetItemSet().GetItemState(nWhich,sal_True)==SFX_ITEM_SET) {
    1103           0 :                 aDefaultAttr.ClearItem(nWhich);
    1104             :             }
    1105           0 :             nWhich=aIter.NextWhich();
    1106           0 :         }
    1107             :     }
    1108             : #ifdef DBG_UTIL
    1109             :     if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
    1110             : #endif
    1111        1344 : }
    1112             : 
    1113           0 : sal_Bool SdrPaintView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const
    1114             : {
    1115           0 :     if(bOnlyHardAttr || !pDefaultStyleSheet)
    1116             :     {
    1117           0 :         rTargetSet.Put(aDefaultAttr, sal_False);
    1118             :     }
    1119             :     else
    1120             :     {
    1121             :         // else merge with DefStyleSheet
    1122           0 :         rTargetSet.Put(pDefaultStyleSheet->GetItemSet(), sal_False);
    1123           0 :         rTargetSet.Put(aDefaultAttr, sal_False);
    1124             :     }
    1125           0 :     MergeNotPersistDefaultAttr(rTargetSet, bOnlyHardAttr);
    1126           0 :     return sal_True;
    1127             : }
    1128             : 
    1129           0 : sal_Bool SdrPaintView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
    1130             : {
    1131           0 :     SetDefaultAttr(rSet,bReplaceAll);
    1132           0 :     return sal_True;
    1133             : }
    1134             : 
    1135           0 : SfxStyleSheet* SdrPaintView::GetStyleSheet() const
    1136             : {
    1137           0 :     return GetDefaultStyleSheet();
    1138             : }
    1139             : 
    1140           0 : sal_Bool SdrPaintView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
    1141             : {
    1142           0 :     SetDefaultStyleSheet(pStyleSheet,bDontRemoveHardAttr);
    1143           0 :     return sal_True;
    1144             : }
    1145             : 
    1146             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1147             : 
    1148             : #ifdef DBG_UTIL
    1149             : void SdrPaintView::ShowItemBrowser(sal_Bool bShow)
    1150             : {
    1151             :     if (bShow) {
    1152             :         if (pItemBrowser==NULL) {
    1153             :             pItemBrowser=new SdrItemBrowser(*(SdrView*)this);
    1154             :             pItemBrowser->SetFloatingMode(sal_True);
    1155             :         }
    1156             :         pItemBrowser->Show();
    1157             :         pItemBrowser->GrabFocus();
    1158             :     } else {
    1159             :         if (pItemBrowser!=NULL) {
    1160             :             pItemBrowser->Hide();
    1161             :             delete pItemBrowser;
    1162             :             pItemBrowser=NULL;
    1163             :         }
    1164             :     }
    1165             : }
    1166             : #endif
    1167             : 
    1168           0 : void SdrPaintView::MakeVisible(const Rectangle& rRect, Window& rWin)
    1169             : {
    1170           0 :     MapMode aMap(rWin.GetMapMode());
    1171           0 :     Size aActualSize(rWin.GetOutputSize());
    1172             : 
    1173           0 :     if( aActualSize.Height() > 0 && aActualSize.Width() > 0 )
    1174             :     {
    1175           0 :         Size aNewSize(rRect.GetSize());
    1176           0 :         sal_Bool bNewScale=sal_False;
    1177           0 :         sal_Bool bNeedMoreX=aNewSize.Width()>aActualSize.Width();
    1178           0 :         sal_Bool bNeedMoreY=aNewSize.Height()>aActualSize.Height();
    1179           0 :         if (bNeedMoreX || bNeedMoreY)
    1180             :         {
    1181           0 :             bNewScale=sal_True;
    1182             :             // set new MapMode (Size+Org) and invalidate everything
    1183           0 :             Fraction aXFact(aNewSize.Width(),aActualSize.Width());
    1184           0 :             Fraction aYFact(aNewSize.Height(),aActualSize.Height());
    1185           0 :             if (aYFact>aXFact) aXFact=aYFact;
    1186           0 :             aXFact*=aMap.GetScaleX();
    1187           0 :             aXFact.ReduceInaccurate(10); // to avoid runovers and BigInt mapping
    1188           0 :             aMap.SetScaleX(aXFact);
    1189           0 :             aMap.SetScaleY(aYFact);
    1190           0 :             rWin.SetMapMode(aMap);
    1191           0 :             aActualSize=rWin.GetOutputSize();
    1192             :         }
    1193           0 :         Point aOrg(aMap.GetOrigin());
    1194           0 :         long dx=0,dy=0;
    1195           0 :         long l=-aOrg.X();
    1196           0 :         long r=-aOrg.X()+aActualSize.Width()-1;
    1197           0 :         long o=-aOrg.Y();
    1198           0 :         long u=-aOrg.Y()+aActualSize.Height()-1;
    1199           0 :         if (l>rRect.Left()) dx=rRect.Left()-l;
    1200           0 :         else if (r<rRect.Right()) dx=rRect.Right()-r;
    1201           0 :         if (o>rRect.Top()) dy=rRect.Top()-o;
    1202           0 :         else if (u<rRect.Bottom()) dy=rRect.Bottom()-u;
    1203           0 :         aMap.SetOrigin(Point(aOrg.X()-dx,aOrg.Y()-dy));
    1204           0 :         if (!bNewScale) {
    1205           0 :             if (dx!=0 || dy!=0) {
    1206           0 :                 rWin.Scroll(-dx,-dy);
    1207           0 :                 rWin.SetMapMode(aMap);
    1208           0 :                 rWin.Update();
    1209             :             }
    1210             :         } else {
    1211           0 :             rWin.SetMapMode(aMap);
    1212           0 :             InvalidateOneWin(rWin);
    1213             :         }
    1214           0 :     }
    1215           0 : }
    1216             : 
    1217           0 : void SdrPaintView::DoConnect(SdrOle2Obj* /*pOleObj*/)
    1218             : {
    1219           0 : }
    1220             : 
    1221        3262 : void SdrPaintView::SetAnimationEnabled( sal_Bool bEnable )
    1222             : {
    1223        3262 :     SetAnimationMode( bEnable ? SDR_ANIMATION_ANIMATE : SDR_ANIMATION_DISABLE );
    1224        3262 : }
    1225             : 
    1226           0 : void SdrPaintView::SetAnimationPause( bool bSet )
    1227             : {
    1228           0 :     if((bool)bAnimationPause != bSet)
    1229             :     {
    1230           0 :         bAnimationPause = bSet;
    1231             : 
    1232           0 :         if(mpPageView)
    1233             :         {
    1234           0 :             for(sal_uInt32 b(0L); b < mpPageView->PageWindowCount(); b++)
    1235             :             {
    1236           0 :                 const SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b));
    1237           0 :                 sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
    1238           0 :                 sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
    1239             : 
    1240           0 :                 if(rAnimator.IsPaused() != bSet)
    1241             :                 {
    1242           0 :                     rAnimator.SetPaused(bSet);
    1243             :                 }
    1244             :             }
    1245             :         }
    1246             :     }
    1247           0 : }
    1248             : 
    1249        3262 : void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode )
    1250             : {
    1251        3262 :     eAnimationMode = eMode;
    1252        3262 : }
    1253             : 
    1254        1204 : void SdrPaintView::VisAreaChanged(const OutputDevice* pOut)
    1255             : {
    1256        1204 :     if(mpPageView)
    1257             :     {
    1258        1202 :         if (pOut)
    1259             :         {
    1260        1082 :             SdrPageWindow* pWindow = mpPageView->FindPageWindow(*((OutputDevice*)pOut));
    1261             : 
    1262        1082 :             if(pWindow)
    1263             :             {
    1264        1082 :                 VisAreaChanged(*pWindow);
    1265             :             }
    1266             :         }
    1267             :         else
    1268             :         {
    1269         240 :             for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
    1270             :             {
    1271         120 :                 VisAreaChanged(*mpPageView->GetPageWindow(a));
    1272             :             }
    1273             :         }
    1274             :     }
    1275        1204 : }
    1276             : 
    1277        1202 : void SdrPaintView::VisAreaChanged(const SdrPageWindow& /*rWindow*/)
    1278             : {
    1279             :     // notify SfxListener
    1280        1202 :     Broadcast(SvxViewHint(SvxViewHint::SVX_HINT_VIEWCHANGED));
    1281        1202 : }
    1282             : 
    1283        1344 : void SdrPaintView::onChangeColorConfig()
    1284             : {
    1285        1344 :     SetGridColor( Color( maColorConfig.GetColorValue( svtools::DRAWGRID ).nColor ) );
    1286        1344 : }
    1287             : 
    1288        1344 : void SdrPaintView::SetGridColor( Color aColor )
    1289             : {
    1290        1344 :     maGridColor = aColor;
    1291        1344 : }
    1292             : 
    1293           8 : Color SdrPaintView::GetGridColor() const
    1294             : {
    1295           8 :     return maGridColor;
    1296             : }
    1297             : 
    1298             : // Set background color for svx at SdrPageViews
    1299           0 : void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor)
    1300             : {
    1301           0 :     if(mpPageView)
    1302             :     {
    1303           0 :         mpPageView->SetApplicationBackgroundColor(aBackgroundColor);
    1304             :     }
    1305           0 : }
    1306             : 
    1307             : // Set document color for svx at SdrPageViews
    1308           0 : void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor)
    1309             : {
    1310           0 :     if(mpPageView)
    1311             :     {
    1312           0 :         mpPageView->SetApplicationDocumentColor(aDocumentColor);
    1313             :     }
    1314           0 : }
    1315             : 
    1316         695 : bool SdrPaintView::IsBufferedOutputAllowed() const
    1317             : {
    1318         695 :     return (mbBufferedOutputAllowed && maDrawinglayerOpt.IsPaintBuffer());
    1319             : }
    1320             : 
    1321         512 : void SdrPaintView::SetBufferedOutputAllowed(bool bNew)
    1322             : {
    1323         512 :     if(bNew != (bool)mbBufferedOutputAllowed)
    1324             :     {
    1325         512 :         mbBufferedOutputAllowed = bNew;
    1326             :     }
    1327         512 : }
    1328             : 
    1329         838 : bool SdrPaintView::IsBufferedOverlayAllowed() const
    1330             : {
    1331         838 :     return (mbBufferedOverlayAllowed && maDrawinglayerOpt.IsOverlayBuffer());
    1332             : }
    1333             : 
    1334         512 : void SdrPaintView::SetBufferedOverlayAllowed(bool bNew)
    1335             : {
    1336         512 :     if(bNew != (bool)mbBufferedOverlayAllowed)
    1337             :     {
    1338         512 :         mbBufferedOverlayAllowed = bNew;
    1339             :     }
    1340         512 : }
    1341             : 
    1342           0 : sal_Bool SdrPaintView::IsPagePaintingAllowed() const
    1343             : {
    1344           0 :     return mbPagePaintingAllowed;
    1345             : }
    1346             : 
    1347           0 : void SdrPaintView::SetPagePaintingAllowed(bool bNew)
    1348             : {
    1349           0 :     if(bNew != (bool)mbPagePaintingAllowed)
    1350             :     {
    1351           0 :         mbPagePaintingAllowed = bNew;
    1352             :     }
    1353           0 : }
    1354             : 
    1355             : // #i38135# Sets the timer for Object animations and restarts.
    1356           0 : void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime)
    1357             : {
    1358           0 :     if(mpPageView)
    1359             :     {
    1360             :         // first, reset all timers at all windows to 0L
    1361           0 :         for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
    1362             :         {
    1363           0 :             const SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a);
    1364           0 :             sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
    1365           0 :             sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
    1366           0 :             rAnimator.SetTime(nTime);
    1367             :         }
    1368             :     }
    1369           0 : }
    1370             : 
    1371             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10