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

Generated by: LCOV version 1.10