LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/dlged - dlgedview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-12-27 Functions: 0 12 0.0 %
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 "dlgedview.hxx"
      21             : #include "dlged.hxx"
      22             : #include <dlgedpage.hxx>
      23             : 
      24             : #include <svx/svxids.hrc>
      25             : #include <sfx2/viewfrm.hxx>
      26             : 
      27             : #include <basidesh.hxx>
      28             : #include <iderdll.hxx>
      29             : #include "dlgedobj.hxx"
      30             : 
      31             : namespace basctl
      32             : {
      33             : 
      34           0 : TYPEINIT1( DlgEdView, SdrView );
      35             : 
      36             : //----------------------------------------------------------------------------
      37             : 
      38           0 : DlgEdView::DlgEdView (SdrModel& rModel, OutputDevice& rOut, DlgEditor& rEditor) :
      39             :     SdrView(&rModel, &rOut),
      40           0 :     rDlgEditor(rEditor)
      41             : {
      42             :     // #114898#
      43           0 :     SetBufferedOutputAllowed(true);
      44           0 :     SetBufferedOverlayAllowed(true);
      45           0 : }
      46             : 
      47             : //----------------------------------------------------------------------------
      48             : 
      49           0 : DlgEdView::~DlgEdView()
      50             : {
      51           0 : }
      52             : 
      53             : //----------------------------------------------------------------------------
      54             : 
      55           0 : void DlgEdView::MarkListHasChanged()
      56             : {
      57           0 :     SdrView::MarkListHasChanged();
      58             : 
      59           0 :     DlgEdHint aHint( DlgEdHint::SELECTIONCHANGED );
      60           0 :     rDlgEditor.Broadcast( aHint );
      61           0 :     rDlgEditor.UpdatePropertyBrowserDelayed();
      62           0 : }
      63             : 
      64             : //----------------------------------------------------------------------------
      65             : 
      66           0 : void DlgEdView::MakeVisible( const Rectangle& rRect, Window& rWin )
      67             : {
      68             :     // visible area
      69           0 :     MapMode aMap( rWin.GetMapMode() );
      70           0 :     Point aOrg( aMap.GetOrigin() );
      71           0 :     Size aVisSize( rWin.GetOutputSize() );
      72           0 :     Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
      73           0 :     Rectangle aVisRect( RectTmp );
      74             : 
      75             :     // check, if rectangle is inside visible area
      76           0 :     if ( !aVisRect.IsInside( rRect ) )
      77             :     {
      78             :         // calculate scroll distance; the rectangle must be inside the visible area
      79           0 :         sal_Int32 nScrollX = 0, nScrollY = 0;
      80             : 
      81           0 :         sal_Int32 nVisLeft   = aVisRect.Left();
      82           0 :         sal_Int32 nVisRight  = aVisRect.Right();
      83           0 :         sal_Int32 nVisTop    = aVisRect.Top();
      84           0 :         sal_Int32 nVisBottom = aVisRect.Bottom();
      85             : 
      86           0 :         sal_Int32 nDeltaX = rDlgEditor.GetHScroll()->GetLineSize();
      87           0 :         sal_Int32 nDeltaY = rDlgEditor.GetVScroll()->GetLineSize();
      88             : 
      89           0 :         while ( rRect.Right() > nVisRight + nScrollX )
      90           0 :             nScrollX += nDeltaX;
      91             : 
      92           0 :         while ( rRect.Left() < nVisLeft + nScrollX )
      93           0 :             nScrollX -= nDeltaX;
      94             : 
      95           0 :         while ( rRect.Bottom() > nVisBottom + nScrollY )
      96           0 :             nScrollY += nDeltaY;
      97             : 
      98           0 :         while ( rRect.Top() < nVisTop + nScrollY )
      99           0 :             nScrollY -= nDeltaY;
     100             : 
     101             :         // don't scroll beyond the page size
     102           0 :         Size aPageSize = rDlgEditor.GetPage().GetSize();
     103           0 :         sal_Int32 nPageWidth  = aPageSize.Width();
     104           0 :         sal_Int32 nPageHeight = aPageSize.Height();
     105             : 
     106           0 :         if ( nVisRight + nScrollX > nPageWidth )
     107           0 :             nScrollX = nPageWidth - nVisRight;
     108             : 
     109           0 :         if ( nVisLeft + nScrollX < 0 )
     110           0 :             nScrollX = -nVisLeft;
     111             : 
     112           0 :         if ( nVisBottom + nScrollY > nPageHeight )
     113           0 :             nScrollY = nPageHeight - nVisBottom;
     114             : 
     115           0 :         if ( nVisTop + nScrollY < 0 )
     116           0 :             nScrollY = -nVisTop;
     117             : 
     118             :         // scroll window
     119           0 :         rWin.Update();
     120           0 :         rWin.Scroll( -nScrollX, -nScrollY );
     121           0 :         aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
     122           0 :         rWin.SetMapMode( aMap );
     123           0 :         rWin.Update();
     124           0 :         rWin.Invalidate();
     125             : 
     126             :         // update scroll bars
     127           0 :         rDlgEditor.UpdateScrollBars();
     128             : 
     129           0 :         DlgEdHint aHint( DlgEdHint::WINDOWSCROLLED );
     130           0 :         rDlgEditor.Broadcast( aHint );
     131           0 :     }
     132           0 : }
     133             : 
     134             : //----------------------------------------------------------------------------
     135             : 
     136           0 : SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol)
     137             : {
     138           0 :     DlgEdObj* pDlgEdObj = dynamic_cast< DlgEdObj* >(pRetval);
     139             : 
     140           0 :     if(pDlgEdObj)
     141             :     {
     142           0 :         bool bExcludeInner(false);
     143             : 
     144           0 :         if(0 != dynamic_cast< DlgEdForm* >(pRetval))
     145             :         {
     146             :             // from DlgEdForm::CheckHit; exclude inner for DlgEdForm
     147           0 :             bExcludeInner = true;
     148             :         }
     149           0 :         else if(pDlgEdObj->supportsService("com.sun.star.awt.UnoControlGroupBoxModel"))
     150             :         {
     151             :             // from DlgEdObj::CheckHit; exclude inner for group shapes
     152           0 :             bExcludeInner = true;
     153             :         }
     154             : 
     155           0 :         if(bExcludeInner)
     156             :         {
     157             :             // use direct model data; it's a DlgEdObj, so GetLastBoundRect()
     158             :             // will access aOutRect directly
     159           0 :             const Rectangle aOuterRectangle(pDlgEdObj->GetLastBoundRect());
     160             : 
     161           0 :             if(!aOuterRectangle.IsEmpty()
     162           0 :                 && RECT_EMPTY != aOuterRectangle.Right()
     163           0 :                 && RECT_EMPTY != aOuterRectangle.Bottom())
     164             :             {
     165             :                 basegfx::B2DRange aOuterRange(
     166           0 :                     aOuterRectangle.Left(), aOuterRectangle.Top(),
     167           0 :                     aOuterRectangle.Right(), aOuterRectangle.Bottom());
     168             : 
     169           0 :                 if(nTol)
     170             :                 {
     171           0 :                     aOuterRange.grow(-1.0 * nTol);
     172             :                 }
     173             : 
     174           0 :                 if(aOuterRange.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
     175             :                 {
     176           0 :                     pRetval = 0;
     177             :                 }
     178             :             }
     179             :         }
     180             :     }
     181             : 
     182           0 :     return pRetval;
     183             : }
     184             : 
     185           0 : SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const
     186             : {
     187             :     // call parent
     188           0 :     SdrObject* pRetval = SdrView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
     189             : 
     190           0 :     if(pRetval)
     191             :     {
     192             :         // check hitted object locally
     193           0 :         pRetval = impLocalHitCorrection(pRetval, rPnt, nTol);
     194             :     }
     195             : 
     196           0 :     return pRetval;
     197             : }
     198             : 
     199             : } // namespace basctl
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10