LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - SectionView.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 121 0.0 %
Date: 2014-04-14 Functions: 0 16 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             : #include "SectionView.hxx"
      20             : #include "DesignView.hxx"
      21             : #include <RptPage.hxx>
      22             : #include <RptObject.hxx>
      23             : #include <RptDef.hxx>
      24             : #include <svx/svxids.hrc>
      25             : #include <svx/svddrgmt.hxx>
      26             : #include <vcl/scrbar.hxx>
      27             : #include "ReportSection.hxx"
      28             : #include "ReportWindow.hxx"
      29             : #include "uistrings.hrc"
      30             : #include <tools/debug.hxx>
      31             : #include <tools/diagnose_ex.h>
      32             : 
      33             : namespace rptui
      34             : {
      35             :     using namespace ::com::sun::star;
      36           0 : TYPEINIT1( OSectionView, SdrView );
      37             : 
      38             : 
      39           0 : OSectionView::OSectionView( SdrModel* pModel, OReportSection* _pSectionWindow, OReportWindow* pEditor )
      40             :     :SdrView( pModel, _pSectionWindow )
      41             :     ,m_pReportWindow( pEditor )
      42           0 :     ,m_pSectionWindow(_pSectionWindow)
      43             : {
      44             :     // SetPagePaintingAllowed(false);
      45           0 :     SetBufferedOutputAllowed(true);
      46           0 :     SetBufferedOverlayAllowed(true);
      47           0 :     SetPageBorderVisible(false);
      48           0 :     SetBordVisible();
      49           0 :     SetQuickTextEditMode(false);
      50           0 : }
      51             : 
      52             : 
      53             : 
      54           0 : OSectionView::~OSectionView()
      55             : {
      56           0 : }
      57             : 
      58             : 
      59             : 
      60           0 : void OSectionView::MarkListHasChanged()
      61             : {
      62           0 :     SdrView::MarkListHasChanged();
      63             : 
      64           0 :     if ( m_pReportWindow && m_pSectionWindow && !m_pSectionWindow->getPage()->getSpecialMode() )
      65             :     {
      66           0 :         DlgEdHint aHint( RPTUI_HINT_SELECTIONCHANGED );
      67           0 :         m_pReportWindow->getReportView()->Broadcast( aHint );
      68           0 :         m_pReportWindow->getReportView()->UpdatePropertyBrowserDelayed(*this);
      69             :     }
      70           0 : }
      71             : 
      72             : 
      73             : 
      74           0 : void OSectionView::MakeVisible( const Rectangle& rRect, Window& rWin )
      75             : {
      76             :     // visible area
      77           0 :     MapMode aMap( rWin.GetMapMode() );
      78           0 :     const Point aOrg( aMap.GetOrigin() );
      79           0 :     const Size aVisSize( rWin.GetOutputSize() );
      80           0 :     const Rectangle aVisRect( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
      81             : 
      82             :     // check, if rectangle is inside visible area
      83           0 :     if ( !aVisRect.IsInside( rRect ) )
      84             :     {
      85             :         // calculate scroll distance; the rectangle must be inside the visible area
      86           0 :         sal_Int32 nScrollX = 0, nScrollY = 0;
      87             : 
      88           0 :         const sal_Int32 nVisLeft   = aVisRect.Left();
      89           0 :         const sal_Int32 nVisRight  = aVisRect.Right();
      90           0 :         const sal_Int32 nVisTop    = aVisRect.Top();
      91           0 :         const sal_Int32 nVisBottom = aVisRect.Bottom();
      92             : 
      93             :         // don't scroll beyond the page size
      94           0 :         Size aPageSize = m_pSectionWindow->getPage()->GetSize();
      95           0 :         const sal_Int32 nPageWidth  = aPageSize.Width();
      96           0 :         const sal_Int32 nPageHeight = aPageSize.Height();
      97             : 
      98           0 :         if ( nVisRight + nScrollX > nPageWidth )
      99           0 :             nScrollX = nPageWidth - nVisRight;
     100             : 
     101           0 :         if ( nVisLeft + nScrollX < 0 )
     102           0 :             nScrollX = -nVisLeft;
     103             : 
     104           0 :         if ( nVisBottom + nScrollY > nPageHeight )
     105           0 :             nScrollY = nPageHeight - nVisBottom;
     106             : 
     107           0 :         if ( nVisTop + nScrollY < 0 )
     108           0 :             nScrollY = -nVisTop;
     109             : 
     110             :         // scroll window
     111           0 :         rWin.Update();
     112           0 :         rWin.Scroll( -nScrollX, -nScrollY );
     113           0 :         aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
     114           0 :         rWin.SetMapMode( aMap );
     115           0 :         rWin.Update();
     116           0 :         rWin.Invalidate();
     117             : 
     118           0 :         if ( m_pReportWindow )
     119             :         {
     120           0 :             const DlgEdHint aHint( RPTUI_HINT_WINDOWSCROLLED );
     121           0 :             m_pReportWindow->getReportView()->Broadcast( aHint );
     122             :         }
     123             :     }
     124             :     else
     125             :     {
     126           0 :         rWin.Invalidate(INVALIDATE_NOERASE);
     127           0 :     }
     128           0 : }
     129             : 
     130           0 : void OSectionView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     131             : {
     132           0 :     SdrView::Notify(rBC,rHint);
     133           0 :     if ( rHint.ISA(SdrHint) )
     134             :     {
     135           0 :         const SdrObject* pObj = ((SdrHint&)rHint).GetObject();
     136           0 :         const SdrHintKind eKind = ((SdrHint&)rHint).GetKind();
     137             :         // check for change of selected object
     138           0 :         if(HINT_OBJCHG == eKind && pObj && IsObjMarked(const_cast<SdrObject*>(pObj)))
     139           0 :             AdjustMarkHdl();
     140           0 :         else if ( eKind == HINT_OBJREMOVED )
     141           0 :             ObjectRemovedInAliveMode(pObj);
     142             :     }
     143           0 : }
     144             : 
     145             : 
     146           0 : void OSectionView::ObjectRemovedInAliveMode( const SdrObject* _pObject )
     147             : {
     148           0 :     const SdrMarkList& rMarkedList = GetMarkedObjectList();
     149           0 :     const sal_uLong nMark = rMarkedList.GetMarkCount();
     150             : 
     151           0 :     for( sal_uLong i = 0; i < nMark; i++ )
     152             :     {
     153           0 :         SdrObject* pSdrObj = rMarkedList.GetMark(i)->GetMarkedSdrObj();
     154           0 :         if (_pObject == pSdrObj)
     155             :         {
     156           0 :             SdrPageView*    pPgView = GetSdrPageView();
     157           0 :             BrkAction();
     158           0 :             MarkObj( pSdrObj, pPgView, true );
     159           0 :             break;
     160             :         }
     161             :     }
     162           0 : }
     163             : 
     164             : 
     165           0 : void OSectionView::SetMarkedToLayer( SdrLayerID _nLayerNo )
     166             : {
     167           0 :     if (AreObjectsMarked())
     168             :     {
     169             :         //  #i11702# use SdrUndoObjectLayerChange for undo
     170             :         //  STR_UNDO_SELATTR is "Attributes" - should use a different text later
     171           0 :         BegUndo( );
     172             : 
     173           0 :         const SdrMarkList& rMark = GetMarkedObjectList();
     174           0 :         sal_uLong nCount = rMark.GetMarkCount();
     175           0 :         for (sal_uLong i=0; i<nCount; i++)
     176             :         {
     177           0 :             SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
     178           0 :             if ( pObj->ISA(OCustomShape) )
     179             :             {
     180           0 :                 AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), _nLayerNo) );
     181           0 :                 pObj->SetLayer( _nLayerNo );
     182           0 :                 OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
     183             :                 try
     184             :                 {
     185           0 :                     pBaseObj->getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::makeAny(_nLayerNo == RPT_LAYER_FRONT));
     186             :                 }
     187           0 :                 catch(const uno::Exception&)
     188             :                 {
     189             :                     DBG_UNHANDLED_EXCEPTION();
     190             :                 }
     191             :             }
     192             :         }
     193             : 
     194           0 :         EndUndo();
     195             : 
     196             :         // check mark list now instead of later in a timer
     197           0 :         CheckMarked();
     198           0 :         MarkListHasChanged();
     199             :     }
     200           0 : }
     201             : 
     202           0 : bool OSectionView::OnlyShapesMarked() const
     203             : {
     204           0 :     const SdrMarkList& rMark = GetMarkedObjectList();
     205           0 :     const sal_uLong nCount = rMark.GetMarkCount();
     206           0 :     if ( !nCount )
     207           0 :         return false;
     208           0 :     sal_uLong i=0;
     209           0 :     for (; i<nCount; i++)
     210             :     {
     211           0 :         SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
     212           0 :         if ( !pObj->ISA(OCustomShape) )
     213             :         {
     214           0 :             break;
     215             :         }
     216             :     }
     217           0 :     return i == nCount;
     218             : }
     219             : 
     220           0 : bool OSectionView::IsDragResize() const
     221             : {
     222           0 :     const SdrDragMethod* pDragMethod = GetDragMethod();
     223           0 :     if (pDragMethod)
     224             :     {
     225           0 :         bool bMoveOnly = pDragMethod->getMoveOnly();
     226           0 :         if (bMoveOnly == false)
     227             :         {
     228             :             // current marked components will be resized
     229           0 :             return true;
     230             :         }
     231             :     }
     232           0 :     return false;
     233             : }
     234             : 
     235             : 
     236           0 : short OSectionView::GetLayerIdOfMarkedObjects() const
     237             : {
     238           0 :     short nRet = SHRT_MAX;
     239           0 :     const SdrMarkList &rMrkList = GetMarkedObjectList();
     240           0 :     for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
     241             :     {
     242           0 :         const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     243           0 :         if ( nRet == SHRT_MAX )
     244           0 :             nRet = pObj->GetLayer();
     245           0 :         else if ( nRet != pObj->GetLayer() )
     246             :         {
     247           0 :             nRet = -1;
     248           0 :             break;
     249             :         }
     250             :     }
     251           0 :     if ( nRet == SHRT_MAX )
     252           0 :         nRet = -1;
     253           0 :     return nRet;
     254             : }
     255             : 
     256             : 
     257             : } // rptui
     258             : 
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10