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

Generated by: LCOV version 1.10