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

Generated by: LCOV version 1.10