LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdpagv.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 315 475 66.3 %
Date: 2014-04-11 Functions: 35 45 77.8 %
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 <svx/svdpagv.hxx>
      21             : #include <com/sun/star/awt/XWindow.hpp>
      22             : #include <com/sun/star/awt/PosSize.hpp>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <svx/svdoutl.hxx>
      25             : #include <svx/xpoly.hxx>
      26             : #include <svx/svdouno.hxx>
      27             : #include <svx/svdpage.hxx>
      28             : #include <svx/svdview.hxx>
      29             : 
      30             : #include <svx/svdedxv.hxx>
      31             : #include <editeng/outliner.hxx>
      32             : #include <svx/svdetc.hxx>
      33             : #include <svx/svdobj.hxx>
      34             : #include "svx/svditer.hxx"
      35             : #include <svx/svdogrp.hxx>
      36             : #include <svx/svdtypes.hxx>
      37             : #include <svx/svdoole2.hxx>
      38             : 
      39             : #include <svx/sdr/contact/objectcontactofpageview.hxx>
      40             : #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
      41             : #include <svx/fmview.hxx>
      42             : 
      43             : // for search on vector
      44             : #include <algorithm>
      45             : 
      46             : using namespace ::rtl;
      47             : using namespace ::com::sun::star;
      48             : #include <svx/sdrpagewindow.hxx>
      49             : #include <svx/sdrpaintwindow.hxx>
      50             : 
      51             : 
      52             : 
      53             : // interface to SdrPageWindow
      54             : 
      55       44959 : SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
      56             : {
      57       45015 :     for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
      58             :     {
      59       41736 :         if(&((*a)->GetPaintWindow()) == &rPaintWindow)
      60             :         {
      61       41680 :             return *a;
      62             :         }
      63             :     }
      64             : 
      65        3279 :     return 0L;
      66             : }
      67             : 
      68         410 : const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
      69             : {
      70        1266 :     for (   SdrPageWindowVector::const_iterator loop = maPageWindows.begin();
      71         844 :             loop != maPageWindows.end();
      72             :             ++loop
      73             :         )
      74             :     {
      75         422 :         const SdrPageWindow& rPageWindow( *(*loop) );
      76         422 :         const SdrPaintWindow& rPaintWindow( rPageWindow.GetOriginalPaintWindow() ? *rPageWindow.GetOriginalPaintWindow() : rPageWindow.GetPaintWindow() );
      77         422 :         if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
      78             :         {
      79         410 :             return &rPageWindow;
      80             :         }
      81             :     }
      82             : 
      83           0 :     return NULL;
      84             : }
      85             : 
      86       36058 : SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
      87             : {
      88       62439 :     for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
      89             :     {
      90       36382 :         if(&((*a)->GetPaintWindow().GetOutputDevice()) == &rOutDev)
      91             :         {
      92       10001 :             return *a;
      93             :         }
      94             :     }
      95             : 
      96       26057 :     return 0L;
      97             : }
      98             : 
      99       17469 : SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
     100             : {
     101       17469 :     if(nIndex < maPageWindows.size())
     102             :     {
     103       17469 :         return maPageWindows[nIndex];
     104             :     }
     105             : 
     106           0 :     return 0L;
     107             : }
     108             : 
     109        6101 : void SdrPageView::ClearPageWindows()
     110             : {
     111        8859 :     for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
     112             :     {
     113        2758 :         delete *a;
     114             :     }
     115             : 
     116        6101 :     maPageWindows.clear();
     117        6101 : }
     118             : 
     119        3279 : void SdrPageView::AppendPageWindow(SdrPageWindow& rNew)
     120             : {
     121        3279 :     maPageWindows.push_back(&rNew);
     122        3279 : }
     123             : 
     124         512 : SdrPageWindow* SdrPageView::RemovePageWindow(SdrPageWindow& rOld)
     125             : {
     126         512 :     const SdrPageWindowVector::iterator aFindResult = ::std::find(maPageWindows.begin(), maPageWindows.end(), &rOld);
     127             : 
     128         512 :     if(aFindResult != maPageWindows.end())
     129             :     {
     130             :         // remember return value
     131         512 :         SdrPageWindow* pSdrPageWindow = *aFindResult;
     132         512 :         maPageWindows.erase(aFindResult);
     133         512 :         return pSdrPageWindow;
     134             :     }
     135             : 
     136           0 :     return 0L;
     137             : }
     138             : 
     139             : 
     140             : 
     141        3298 : SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
     142             : :   mrView(rNewView),
     143             :     // col_auto color lets the view takes the default SvxColorConfig entry
     144             :     maDocumentColor( COL_AUTO ),
     145             :     maBackgroundColor(COL_AUTO ), // #i48367# also react on autocolor
     146        3298 :     mpPreparedPageWindow(0) // #i72752#
     147             : {
     148        3298 :     mpPage = pPage1;
     149             : 
     150        3298 :     if(mpPage)
     151             :     {
     152        3298 :         aPgOrg.X()=mpPage->GetLftBorder();
     153        3298 :         aPgOrg.Y()=mpPage->GetUppBorder();
     154             :     }
     155        3298 :     mbHasMarked = false;
     156        3298 :     aLayerVisi.SetAll();
     157        3298 :     aLayerPrn.SetAll();
     158             : 
     159        3298 :     mbVisible = false;
     160        3298 :     pAktList = NULL;
     161        3298 :     pAktGroup = NULL;
     162        3298 :     SetAktGroupAndList(NULL, mpPage);
     163             : 
     164        6574 :     for(sal_uInt32 a(0L); a < rNewView.PaintWindowCount(); a++)
     165             :     {
     166        3276 :         AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
     167             :     }
     168        3298 : }
     169             : 
     170        6578 : SdrPageView::~SdrPageView()
     171             : {
     172             : 
     173             :     // cleanup window vector
     174        3289 :     ClearPageWindows();
     175        3289 : }
     176             : 
     177        3279 : SdrPageWindow& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow& rPaintWindow)
     178             : {
     179        3279 :     SdrPageWindow& rWindow = *(new SdrPageWindow(*this, rPaintWindow));
     180        3279 :     AppendPageWindow(rWindow);
     181             : 
     182        3279 :     return rWindow;
     183             : }
     184             : 
     185        6555 : void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
     186             : {
     187        6555 :     if(!FindPageWindow(rPaintWindow))
     188             :     {
     189        3279 :         CreateNewPageWindowEntry(rPaintWindow);
     190             :     }
     191        6555 : }
     192             : 
     193         512 : void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
     194             : {
     195         512 :     SdrPageWindow* pCandidate = FindPageWindow(rPaintWindow);
     196             : 
     197         512 :     if(pCandidate)
     198             :     {
     199         512 :         pCandidate = RemovePageWindow(*pCandidate);
     200             : 
     201         512 :         if(pCandidate)
     202             :         {
     203         512 :             delete pCandidate;
     204             :         }
     205             :     }
     206         512 : }
     207             : 
     208         410 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
     209             : {
     210         410 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xReturn;
     211         410 :     const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
     212             : 
     213         410 :     if ( pCandidate )
     214         410 :         xReturn = pCandidate->GetControlContainer( true );
     215             : 
     216         410 :     return xReturn;
     217             : }
     218             : 
     219        1184 : void SdrPageView::ModelHasChanged()
     220             : {
     221        1184 :     if (GetAktGroup()!=NULL) CheckAktGroup();
     222        1184 : }
     223             : 
     224           1 : bool SdrPageView::IsReadOnly() const
     225             : {
     226           1 :     return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
     227             : }
     228             : 
     229        3298 : void SdrPageView::Show()
     230             : {
     231        3298 :     if(!IsVisible())
     232             :     {
     233        3298 :         mbVisible = true;
     234        3298 :         InvalidateAllWin();
     235             : 
     236        6574 :         for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
     237             :         {
     238        3276 :             AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
     239             :         }
     240             :     }
     241        3298 : }
     242             : 
     243        2812 : void SdrPageView::Hide()
     244             : {
     245        2812 :     if(IsVisible())
     246             :     {
     247        2812 :         InvalidateAllWin();
     248        2812 :         mbVisible = false;
     249        2812 :         ClearPageWindows();
     250             :     }
     251        2812 : }
     252             : 
     253           0 : Rectangle SdrPageView::GetPageRect() const
     254             : {
     255           0 :     if (GetPage()==NULL) return Rectangle();
     256           0 :     return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
     257             : }
     258             : 
     259       12071 : void SdrPageView::InvalidateAllWin()
     260             : {
     261       12071 :     if(IsVisible() && GetPage())
     262             :     {
     263       12071 :         Rectangle aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
     264       12071 :         aRect.Union(GetPage()->GetAllObjBoundRect());
     265       12071 :         GetView().InvalidateAllWin(aRect);
     266             :     }
     267       12071 : }
     268             : 
     269             : 
     270             : 
     271       14450 : void SdrPageView::PrePaint()
     272             : {
     273       14450 :     const sal_uInt32 nCount(PageWindowCount());
     274             : 
     275       28996 :     for(sal_uInt32 a(0); a < nCount; a++)
     276             :     {
     277       14546 :         SdrPageWindow* pCandidate = GetPageWindow(a);
     278             : 
     279       14546 :         if(pCandidate)
     280             :         {
     281       14546 :             pCandidate->PrePaint();
     282             :         }
     283             :     }
     284       14450 : }
     285             : 
     286        1287 : void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const
     287             : {
     288        1287 :     if(GetPage())
     289             :     {
     290        1287 :         SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
     291        1287 :         bool bIsTempTarget(false);
     292             : 
     293        1287 :         if(!pPageWindow)
     294             :         {
     295             :             // create temp PageWindow
     296           0 :             pPageWindow = new SdrPageWindow(*((SdrPageView*)this), rPaintWindow);
     297           0 :             bIsTempTarget = true;
     298             :         }
     299             : 
     300             :         // do the redraw
     301        1287 :         pPageWindow->PrepareRedraw(rReg);
     302        1287 :         pPageWindow->RedrawAll(pRedirector);
     303             : 
     304             :         // get rid of temp PageWindow
     305        1287 :         if(bIsTempTarget)
     306             :         {
     307           0 :             delete pPageWindow;
     308           0 :             pPageWindow = 0L;
     309             :         }
     310             :     }
     311        1287 : }
     312             : 
     313             : 
     314             : // #i74769# use SdrPaintWindow directly
     315             : 
     316       54792 : void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
     317             : {
     318             :     // #i72752# remember prepared SdrPageWindow
     319       54792 :     mpPreparedPageWindow = pKnownTarget;
     320       54792 : }
     321             : 
     322       26631 : void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector, const Rectangle& rRect) const
     323             : {
     324       26631 :     if(GetPage())
     325             :     {
     326       26631 :         if(pGivenTarget)
     327             :         {
     328       26631 :             const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
     329             : 
     330       26631 :             if(pKnownTarget)
     331             :             {
     332             :                 // paint known target
     333         574 :                 pKnownTarget->RedrawLayer(&nID, pRedirector);
     334             :             }
     335             :             else
     336             :             {
     337             :                 // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
     338             :                 // e.g. when SW paints a single text line in text edit mode. Try to use it
     339       26057 :                 SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
     340             : 
     341       26057 :                 if(pPreparedTarget)
     342             :                 {
     343             :                     // if we have a prepared target, do not use a new SdrPageWindow since this
     344             :                     // works but is expensive. Just use a temporary PaintWindow
     345       26057 :                     SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
     346             : 
     347             :                     // Copy existing paint region to use the same as prepared in BeginDrawLayer
     348       26057 :                     SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
     349       26057 :                     const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
     350       26057 :                     bool bUseRect(false);
     351       26057 :                     if (!rRect.IsEmpty())
     352             :                     {
     353       13576 :                         Region r(rExistingRegion);
     354       13576 :                         r.Intersect(rRect);
     355             :                         // fdo#74435: FIXME: visibility check broken if empty
     356       13576 :                         if (!r.IsEmpty())
     357       13430 :                             bUseRect = true;
     358             :                     }
     359       26057 :                     if (!bUseRect)
     360       12627 :                         aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
     361             :                     else
     362       13430 :                         aTemporaryPaintWindow.SetRedrawRegion(Region(rRect));
     363             : 
     364             :                     // patch the ExistingPageWindow
     365       26057 :                     pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
     366             : 
     367             :                     // redraw the layer
     368       26057 :                     pPreparedTarget->RedrawLayer(&nID, pRedirector);
     369             : 
     370             :                     // restore the ExistingPageWindow
     371       26057 :                     pPreparedTarget->unpatchPaintWindow();
     372             :                 }
     373             :                 else
     374             :                 {
     375             :                     OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
     376             : 
     377             :                     // None of the known OutputDevices is the target of this paint, use
     378             :                     // a temporary SdrPageWindow for this Redraw.
     379           0 :                     SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
     380           0 :                     SdrPageWindow aTemporaryPageWindow(*((SdrPageView*)this), aTemporaryPaintWindow);
     381             : 
     382             :                     // #i72752#
     383             :                     // Copy existing paint region if other PageWindows exist, this was created by
     384             :                     // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
     385             :                     // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
     386           0 :                     if(PageWindowCount())
     387             :                     {
     388           0 :                         SdrPageWindow* pExistingPageWindow = GetPageWindow(0L);
     389           0 :                         SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
     390           0 :                         const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
     391           0 :                         aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
     392             :                     }
     393             : 
     394           0 :                     aTemporaryPageWindow.RedrawLayer(&nID, pRedirector);
     395             :                 }
     396             :             }
     397             :         }
     398             :         else
     399             :         {
     400             :             // paint in all known windows
     401           0 :             for(sal_uInt32 a(0L); a < PageWindowCount(); a++)
     402             :             {
     403           0 :                 SdrPageWindow* pTarget = GetPageWindow(a);
     404           0 :                 pTarget->RedrawLayer(&nID, pRedirector);
     405             :             }
     406             :         }
     407             :     }
     408       26631 : }
     409             : 
     410          14 : void SdrPageView::SetDesignMode( bool _bDesignMode ) const
     411             : {
     412          28 :     for ( sal_uInt32 i = 0L; i < PageWindowCount(); ++i )
     413             :     {
     414          14 :         const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
     415          14 :         rPageViewWindow.SetDesignMode( _bDesignMode );
     416             :     }
     417          14 : }
     418             : 
     419             : 
     420             : 
     421          13 : void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const Rectangle& rRect, Color aColor)
     422             : {
     423          13 :     if (GetPage()==NULL)
     424          13 :         return;
     425             : 
     426          13 :     long nx1=GetView().aGridBig.Width();
     427          13 :     long nx2=GetView().aGridFin.Width();
     428          13 :     long ny1=GetView().aGridBig.Height();
     429          13 :     long ny2=GetView().aGridFin.Height();
     430             : 
     431          13 :     if (nx1==0) nx1=nx2;
     432          13 :     if (nx2==0) nx2=nx1;
     433          13 :     if (ny1==0) ny1=ny2;
     434          13 :     if (ny2==0) ny2=ny1;
     435          13 :     if (nx1==0) { nx1=ny1; nx2=ny2; }
     436          13 :     if (ny1==0) { ny1=nx1; ny2=nx2; }
     437          13 :     if (nx1<0) nx1=-nx1;
     438          13 :     if (nx2<0) nx2=-nx2;
     439          13 :     if (ny1<0) ny1=-ny1;
     440          13 :     if (ny2<0) ny2=-ny2;
     441             : 
     442          13 :     if (nx1!=0)
     443             :     {
     444             :         // no more global output size, use window size instead to decide grid sizes
     445          13 :         long nScreenWdt = rOut.GetOutputSizePixel().Width();
     446             : 
     447          13 :         long nMinDotPix=2;
     448          13 :         long nMinLinPix=4;
     449             : 
     450          13 :         if (nScreenWdt>=1600)
     451             :         {
     452           0 :             nMinDotPix=4;
     453           0 :             nMinLinPix=8;
     454             :         }
     455          13 :         else if (nScreenWdt>=1024)
     456             :         {
     457           0 :             nMinDotPix=3;
     458           0 :             nMinLinPix=6;
     459             :         }
     460             :         else
     461             :         { // e. g. 640x480
     462          13 :             nMinDotPix=2;
     463          13 :             nMinLinPix=4;
     464             :         }
     465          13 :         Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
     466          13 :         Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
     467          13 :         bool bHoriSolid=nx2<aMinDotDist.Width();
     468          13 :         bool bVertSolid=ny2<aMinDotDist.Height();
     469             :         // enlarge line offset (minimum 4 pixels)
     470             :         // enlarge by: *2 *5 *10 *20 *50 *100 ...
     471          13 :         int nTgl=0;
     472          13 :         long nVal0=nx1;
     473          26 :         while (nx1<aMinLinDist.Width())
     474             :         {
     475           0 :             long a=nx1;
     476             : 
     477           0 :             if (nTgl==0) nx1*=2;
     478           0 :             if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
     479           0 :             if (nTgl==2) nx1*=2;
     480             : 
     481           0 :             nVal0=a;
     482           0 :             nTgl++; if (nTgl>=3) nTgl=0;
     483             :         }
     484          13 :         nTgl=0;
     485          13 :         nVal0=ny1;
     486          26 :         while (ny1<aMinLinDist.Height())
     487             :         {
     488           0 :             long a=ny1;
     489             : 
     490           0 :             if (nTgl==0) ny1*=2;
     491           0 :             if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
     492           0 :             if (nTgl==2) ny1*=2;
     493             : 
     494           0 :             nVal0=a;
     495           0 :             nTgl++;
     496             : 
     497           0 :             if (nTgl>=3) nTgl=0;
     498             :         }
     499             : 
     500          13 :         bool bHoriFine=nx2<nx1;
     501          13 :         bool bVertFine=ny2<ny1;
     502          13 :         bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
     503          13 :         bool bVertLines=bVertSolid || bVertFine;
     504             : 
     505          13 :         Color aColorMerk( rOut.GetLineColor() );
     506          13 :         rOut.SetLineColor( aColor );
     507             : 
     508          13 :         bool bMap0=rOut.IsMapModeEnabled();
     509             : 
     510          13 :         long nWrX=0;
     511          13 :         long nWrY=0;
     512          13 :         Point aOrg(aPgOrg);
     513          13 :         long x1=GetPage()->GetLftBorder()+1+nWrX;
     514          13 :         long x2=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY;
     515          13 :         long y1=GetPage()->GetUppBorder()+1+nWrX;
     516          13 :         long y2=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY;
     517          13 :         const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,NULL);
     518             : 
     519          13 :         sal_uInt16 nGridPaintAnz=1;
     520          13 :         if (pFrames!=NULL) nGridPaintAnz=pFrames->GetCount();
     521          26 :         for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintAnz; nGridPaintNum++) {
     522          13 :             if (pFrames!=NULL) {
     523          13 :                 const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
     524          13 :                 nWrX=rGF.GetPaperRect().Left();
     525          13 :                 nWrY=rGF.GetPaperRect().Top();
     526          13 :                 x1=rGF.GetUserArea().Left();
     527          13 :                 x2=rGF.GetUserArea().Right();
     528          13 :                 y1=rGF.GetUserArea().Top();
     529          13 :                 y2=rGF.GetUserArea().Bottom();
     530          13 :                 aOrg=rGF.GetUserArea().TopLeft();
     531          13 :                 aOrg-=rGF.GetPaperRect().TopLeft();
     532             :             }
     533          13 :             if (!rRect.IsEmpty()) {
     534          13 :                 Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
     535          13 :                 long nX1Pix=a1PixSiz.Width();  // add 1 pixel of tolerance
     536          13 :                 long nY1Pix=a1PixSiz.Height();
     537          13 :                 if (x1<rRect.Left()  -nX1Pix) x1=rRect.Left()  -nX1Pix;
     538          13 :                 if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
     539          13 :                 if (y1<rRect.Top()   -nY1Pix) y1=rRect.Top()   -nY1Pix;
     540          13 :                 if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
     541             :             }
     542             : 
     543          13 :             long xBigOrg=aOrg.X()+nWrX;
     544          13 :             while (xBigOrg>=x1) xBigOrg-=nx1;
     545          13 :             while (xBigOrg<x1) xBigOrg+=nx1;
     546          13 :             long xFinOrg=xBigOrg;
     547          13 :             while (xFinOrg>=x1) xFinOrg-=nx2;
     548          13 :             while (xFinOrg<x1) xFinOrg+=nx2;
     549             : 
     550          13 :             long yBigOrg=aOrg.Y()+nWrY;
     551          13 :             while (yBigOrg>=y1) yBigOrg-=ny1;
     552          13 :             while (yBigOrg<y1) yBigOrg+=ny1;
     553          13 :             long yFinOrg=yBigOrg;
     554          13 :             while (yFinOrg>=y1) yFinOrg-=ny2;
     555          13 :             while (yFinOrg<y1) yFinOrg+=ny2;
     556             : 
     557          13 :             if( x1 <= x2 && y1 <= y2 )
     558             :             {
     559          13 :                 if( bHoriLines )
     560             :                 {
     561          13 :                     sal_uIntPtr nGridFlags = ( bHoriSolid ? GRID_HORZLINES : GRID_DOTS );
     562          13 :                     sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
     563          13 :                     sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
     564          13 :                     sal_uInt32 nStepOffset = 0;
     565          13 :                     sal_uInt16 nPointOffset = 0;
     566             : 
     567         134 :                     for(sal_uInt16 a=0;a<nSteps;a++)
     568             :                     {
     569             :                         // draw
     570             :                         rOut.DrawGrid(
     571         121 :                             Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
     572         242 :                             Size( nx1, ny1 ), nGridFlags );
     573             : 
     574             :                         // do a step
     575         121 :                         nStepOffset += nRestPerStepMul1000;
     576         310 :                         while(nStepOffset >= 1000)
     577             :                         {
     578          68 :                             nStepOffset -= 1000;
     579          68 :                             nPointOffset++;
     580             :                         }
     581             :                     }
     582             :                 }
     583             : 
     584          13 :                 if( bVertLines )
     585             :                 {
     586          13 :                     sal_uIntPtr nGridFlags = ( bVertSolid ? GRID_VERTLINES : GRID_DOTS );
     587          13 :                     sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
     588          13 :                     sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
     589          13 :                     sal_uInt32 nStepOffset = 0;
     590          13 :                     sal_uInt16 nPointOffset = 0;
     591             : 
     592         114 :                     for(sal_uInt16 a=0;a<nSteps;a++)
     593             :                     {
     594             :                         // draw
     595             :                         rOut.DrawGrid(
     596         101 :                             Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
     597         202 :                             Size( nx1, ny1 ), nGridFlags );
     598             : 
     599             :                         // do a step
     600         101 :                         nStepOffset += nRestPerStepMul1000;
     601         242 :                         while(nStepOffset >= 1000)
     602             :                         {
     603          40 :                             nStepOffset -= 1000;
     604          40 :                             nPointOffset++;
     605             :                         }
     606             :                     }
     607             :                 }
     608             :             }
     609             :         }
     610             : 
     611          13 :         rOut.EnableMapMode(bMap0);
     612          13 :         rOut.SetLineColor(aColorMerk);
     613             :     }
     614             : }
     615             : 
     616        6903 : void SdrPageView::AdjHdl()
     617             : {
     618        6903 :     GetView().AdjustMarkHdl();
     619        6903 : }
     620             : 
     621        8570 : void SdrPageView::SetLayer(const OUString& rName, SetOfByte& rBS, bool bJa)
     622             : {
     623        8570 :     if(!GetPage())
     624        8570 :         return;
     625             : 
     626        8570 :     SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName, true);
     627             : 
     628        8570 :     if(SDRLAYER_NOTFOUND != nID)
     629        8570 :         rBS.Set(nID, bJa);
     630             : }
     631             : 
     632        6250 : bool SdrPageView::IsLayer(const OUString& rName, const SetOfByte& rBS) const
     633             : {
     634        6250 :     if(!GetPage())
     635           0 :         return false;
     636             : 
     637        6250 :     bool bRet(false);
     638             : 
     639        6250 :     if (!rName.isEmpty())
     640             :     {
     641        6250 :         SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName, true);
     642             : 
     643        6250 :         if(SDRLAYER_NOTFOUND != nId)
     644             :         {
     645        6250 :             bRet = rBS.IsSet(nId);
     646             :         }
     647             :     }
     648             : 
     649        6250 :     return bRet;
     650             : }
     651             : 
     652         405 : bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
     653             : {
     654         405 :     if(pObj)
     655             :     {
     656             :         // excluded from selection?
     657         405 :         if(pObj->IsMarkProtect())
     658             :         {
     659           0 :             return false;
     660             :         }
     661             : 
     662             :         // only visible are selectable
     663         405 :         if( !pObj->IsVisible() )
     664             :         {
     665           0 :             return false;
     666             :         }
     667             : 
     668         405 :         if(pObj->ISA(SdrObjGroup))
     669             :         {
     670             :             // If object is a Group object, visibility may depend on
     671             :             // multiple layers. If one object is markable, Group is markable.
     672          40 :             SdrObjList* pObjList = ((SdrObjGroup*)pObj)->GetSubList();
     673             : 
     674          40 :             if(pObjList && pObjList->GetObjCount())
     675             :             {
     676          37 :                 bool bGroupIsMarkable(false);
     677             : 
     678          74 :                 for(sal_uInt32 a(0L); !bGroupIsMarkable && a < pObjList->GetObjCount(); a++)
     679             :                 {
     680          37 :                     SdrObject* pCandidate = pObjList->GetObj(a);
     681             : 
     682             :                     // call recursively
     683          37 :                     if(IsObjMarkable(pCandidate))
     684             :                     {
     685          37 :                         bGroupIsMarkable = true;
     686             :                     }
     687             :                 }
     688             : 
     689          37 :                 return bGroupIsMarkable;
     690             :             }
     691             :             else
     692             :             {
     693             :                 // #i43302#
     694             :                 // Allow empty groups to be selected to be able to delete them
     695           3 :                 return true;
     696             :             }
     697             :         }
     698             :         else
     699             :         {
     700             :             // the layer has to be visible and must not be locked
     701         365 :             SdrLayerID nL = pObj->GetLayer();
     702         365 :             return (aLayerVisi.IsSet(sal_uInt8(nL)) && !aLayerLock.IsSet(sal_uInt8(nL)));
     703             :         }
     704             :     }
     705             : 
     706           0 :     return false;
     707             : }
     708             : 
     709           0 : void SdrPageView::SetPageOrigin(const Point& rOrg)
     710             : {
     711           0 :     if (rOrg!=aPgOrg) {
     712           0 :         aPgOrg=rOrg;
     713           0 :         if (GetView().IsGridVisible()) {
     714           0 :             InvalidateAllWin();
     715             :         }
     716             :     }
     717           0 : }
     718             : 
     719           0 : void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
     720             : {
     721           0 :     if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
     722           0 :         const SdrHelpLine& rHL=aHelpLines[nNum];
     723             : 
     724           0 :         for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
     725             :         {
     726           0 :             SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
     727             : 
     728           0 :             if(pCandidate->OutputToWindow())
     729             :             {
     730           0 :                 OutputDevice& rOutDev = pCandidate->GetOutputDevice();
     731           0 :                 Rectangle aR(rHL.GetBoundRect(rOutDev));
     732           0 :                 Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
     733           0 :                 aR.Left() -= aSiz.Width();
     734           0 :                 aR.Right() += aSiz.Width();
     735           0 :                 aR.Top() -= aSiz.Height();
     736           0 :                 aR.Bottom() += aSiz.Height();
     737           0 :                 ((SdrView&)GetView()).InvalidateOneWin((Window&)rOutDev, aR);
     738             :             }
     739             :         }
     740             :     }
     741           0 : }
     742             : 
     743          78 : void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
     744             : {
     745          78 :     aHelpLines=rHLL;
     746          78 :     InvalidateAllWin();
     747          78 : }
     748             : 
     749           0 : void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
     750             : {
     751           0 :     if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
     752           0 :         bool bNeedRedraw = true;
     753           0 :         if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
     754           0 :             switch (rNewHelpLine.GetKind()) {
     755           0 :                 case SDRHELPLINE_VERTICAL  : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
     756           0 :                 case SDRHELPLINE_HORIZONTAL: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
     757           0 :                 default: break;
     758             :             } // switch
     759             :         }
     760           0 :         if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
     761           0 :         aHelpLines[nNum]=rNewHelpLine;
     762           0 :         if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
     763             :     }
     764           0 : }
     765             : 
     766           0 : void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
     767             : {
     768           0 :     if (nNum<aHelpLines.GetCount()) {
     769           0 :         ImpInvalidateHelpLineArea(nNum);
     770           0 :         aHelpLines.Delete(nNum);
     771             :     }
     772           0 : }
     773             : 
     774           0 : void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL, sal_uInt16 nNum)
     775             : {
     776           0 :     if (nNum > aHelpLines.GetCount())
     777           0 :         nNum = aHelpLines.GetCount();
     778           0 :     aHelpLines.Insert(rHL,nNum);
     779           0 :     if (GetView().IsHlplVisible())
     780           0 :         ImpInvalidateHelpLineArea(nNum);
     781           0 : }
     782             : 
     783             : // set current group and list
     784        3298 : void SdrPageView::SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
     785             : {
     786        3298 :     if(pAktGroup != pNewGroup)
     787             :     {
     788           0 :         pAktGroup = pNewGroup;
     789             :     }
     790        3298 :     if(pAktList != pNewList)
     791             :     {
     792        3298 :         pAktList = pNewList;
     793             :     }
     794        3298 : }
     795             : 
     796           0 : bool SdrPageView::EnterGroup(SdrObject* pObj)
     797             : {
     798           0 :     bool bRet(false);
     799             : 
     800           0 :     if(pObj && pObj->IsGroupObject())
     801             :     {
     802           0 :         bool bGlueInvalidate(GetView().ImpIsGlueVisible());
     803             : 
     804           0 :         if(bGlueInvalidate)
     805             :         {
     806           0 :             GetView().GlueInvalidate();
     807             :         }
     808             : 
     809             :         // deselect all
     810           0 :         GetView().UnmarkAll();
     811             : 
     812             :         // set current group and list
     813           0 :         SdrObjList* pNewObjList = pObj->GetSubList();
     814           0 :         SetAktGroupAndList(pObj, pNewObjList);
     815             : 
     816             :         // select contained object if only one object is contained,
     817             :         // else select nothing and let the user decide what to do next
     818           0 :         if(pNewObjList && pNewObjList->GetObjCount() == 1)
     819             :         {
     820           0 :             SdrObject* pFirstObject = pNewObjList->GetObj(0L);
     821             : 
     822           0 :             if(GetView().GetSdrPageView())
     823             :             {
     824           0 :                 GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
     825             :             }
     826             :         }
     827             : 
     828             :         // build new handles
     829           0 :         GetView().AdjustMarkHdl();
     830             : 
     831             :         // invalidate only when view wants to visualize group entering
     832           0 :         if(GetView().DoVisualizeEnteredGroup())
     833             :         {
     834           0 :             InvalidateAllWin();
     835             :         }
     836             : 
     837           0 :         if (bGlueInvalidate)
     838             :         {
     839           0 :             GetView().GlueInvalidate();
     840             :         }
     841             : 
     842           0 :         bRet = true;
     843             :     }
     844             : 
     845           0 :     return bRet;
     846             : }
     847             : 
     848           0 : void SdrPageView::LeaveOneGroup()
     849             : {
     850           0 :     if(GetAktGroup())
     851             :     {
     852           0 :         bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
     853             : 
     854           0 :         if(bGlueInvalidate)
     855           0 :             GetView().GlueInvalidate();
     856             : 
     857           0 :         SdrObject* pLastGroup = GetAktGroup();
     858           0 :         SdrObject* pParentGroup = GetAktGroup()->GetUpGroup();
     859           0 :         SdrObjList* pParentList = GetPage();
     860             : 
     861           0 :         if(pParentGroup)
     862           0 :             pParentList = pParentGroup->GetSubList();
     863             : 
     864             :         // deselect everything
     865           0 :         GetView().UnmarkAll();
     866             : 
     867             :         // allocations, pAktGroup and pAktList need to be set
     868           0 :         SetAktGroupAndList(pParentGroup, pParentList);
     869             : 
     870             :         // select the group we just left
     871           0 :         if(pLastGroup)
     872           0 :             if(GetView().GetSdrPageView())
     873           0 :                 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
     874             : 
     875           0 :         GetView().AdjustMarkHdl();
     876             : 
     877             :         // invalidate only if view wants to visualize group entering
     878           0 :         if(GetView().DoVisualizeEnteredGroup())
     879           0 :             InvalidateAllWin();
     880             : 
     881           0 :         if(bGlueInvalidate)
     882           0 :             GetView().GlueInvalidate();
     883             :     }
     884           0 : }
     885             : 
     886           0 : void SdrPageView::LeaveAllGroup()
     887             : {
     888           0 :     if(GetAktGroup())
     889             :     {
     890           0 :         bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
     891             : 
     892           0 :         if(bGlueInvalidate)
     893           0 :             GetView().GlueInvalidate();
     894             : 
     895           0 :         SdrObject* pLastGroup = GetAktGroup();
     896             : 
     897             :         // deselect everything
     898           0 :         GetView().UnmarkAll();
     899             : 
     900             :         // allocations, pAktGroup and pAktList always need to be set
     901           0 :         SetAktGroupAndList(NULL, GetPage());
     902             : 
     903             :         // find and select uppermost group
     904           0 :         if(pLastGroup)
     905             :         {
     906           0 :             while(pLastGroup->GetUpGroup())
     907           0 :                 pLastGroup = pLastGroup->GetUpGroup();
     908             : 
     909           0 :             if(GetView().GetSdrPageView())
     910           0 :                 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
     911             :         }
     912             : 
     913           0 :         GetView().AdjustMarkHdl();
     914             : 
     915             :         // invalidate only when view wants to visualize group entering
     916           0 :         if(GetView().DoVisualizeEnteredGroup())
     917           0 :             InvalidateAllWin();
     918             : 
     919           0 :         if(bGlueInvalidate)
     920           0 :             GetView().GlueInvalidate();
     921             :     }
     922           0 : }
     923             : 
     924        2791 : sal_uInt16 SdrPageView::GetEnteredLevel() const
     925             : {
     926        2791 :     sal_uInt16 nAnz=0;
     927        2791 :     SdrObject* pGrp=GetAktGroup();
     928        5582 :     while (pGrp!=NULL) {
     929           0 :         nAnz++;
     930           0 :         pGrp=pGrp->GetUpGroup();
     931             :     }
     932        2791 :     return nAnz;
     933             : }
     934             : 
     935           0 : void SdrPageView::CheckAktGroup()
     936             : {
     937           0 :     SdrObject* pGrp=GetAktGroup();
     938           0 :     while (pGrp!=NULL &&
     939           0 :            (!pGrp->IsInserted() || pGrp->GetObjList()==NULL ||
     940           0 :             pGrp->GetPage()==NULL || pGrp->GetModel()==NULL)) { // anything outside of the borders?
     941           0 :         pGrp=pGrp->GetUpGroup();
     942             :     }
     943           0 :     if (pGrp!=GetAktGroup()) {
     944           0 :         if (pGrp!=NULL) EnterGroup(pGrp);
     945           0 :         else LeaveAllGroup();
     946             :     }
     947           0 : }
     948             : 
     949             : // Set background color for svx at SdrPageViews
     950         931 : void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
     951             : {
     952         931 :     maBackgroundColor = aBackgroundColor;
     953         931 : }
     954             : 
     955         530 : Color SdrPageView::GetApplicationBackgroundColor() const
     956             : {
     957         530 :     return maBackgroundColor;
     958             : }
     959             : 
     960             : // Set document color for svx at SdrPageViews
     961         134 : void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
     962             : {
     963         134 :     maDocumentColor = aDocumentColor;
     964         134 : }
     965             : 
     966        2180 : Color SdrPageView::GetApplicationDocumentColor() const
     967             : {
     968        2180 :     return maDocumentColor;
     969             : }
     970             : 
     971             : 
     972             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10