LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - SectionView.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 122 0.8 %
Date: 2014-11-03 Functions: 2 18 11.1 %
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, vcl::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 :     const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint);
     134           0 :     if ( pSdrHint )
     135             :     {
     136           0 :         const SdrObject* pObj = pSdrHint->GetObject();
     137           0 :         const SdrHintKind eKind = pSdrHint->GetKind();
     138             :         // check for change of selected object
     139           0 :         if(HINT_OBJCHG == eKind && pObj && IsObjMarked(const_cast<SdrObject*>(pObj)))
     140           0 :             AdjustMarkHdl();
     141           0 :         else if ( eKind == HINT_OBJREMOVED )
     142           0 :             ObjectRemovedInAliveMode(pObj);
     143             :     }
     144           0 : }
     145             : 
     146             : 
     147           0 : void OSectionView::ObjectRemovedInAliveMode( const SdrObject* _pObject )
     148             : {
     149           0 :     const SdrMarkList& rMarkedList = GetMarkedObjectList();
     150           0 :     const size_t nMark = rMarkedList.GetMarkCount();
     151             : 
     152           0 :     for( size_t i = 0; i < nMark; ++i )
     153             :     {
     154           0 :         SdrObject* pSdrObj = rMarkedList.GetMark(i)->GetMarkedSdrObj();
     155           0 :         if (_pObject == pSdrObj)
     156             :         {
     157           0 :             SdrPageView*    pPgView = GetSdrPageView();
     158           0 :             BrkAction();
     159           0 :             MarkObj( pSdrObj, pPgView, true );
     160           0 :             break;
     161             :         }
     162             :     }
     163           0 : }
     164             : 
     165             : 
     166           0 : void OSectionView::SetMarkedToLayer( SdrLayerID _nLayerNo )
     167             : {
     168           0 :     if (AreObjectsMarked())
     169             :     {
     170             :         //  #i11702# use SdrUndoObjectLayerChange for undo
     171             :         //  STR_UNDO_SELATTR is "Attributes" - should use a different text later
     172           0 :         BegUndo( );
     173             : 
     174           0 :         const SdrMarkList& rMark = GetMarkedObjectList();
     175           0 :         const size_t nCount = rMark.GetMarkCount();
     176           0 :         for (size_t i = 0; i<nCount; ++i)
     177             :         {
     178           0 :             SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
     179           0 :             if ( pObj->ISA(OCustomShape) )
     180             :             {
     181           0 :                 AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), _nLayerNo) );
     182           0 :                 pObj->SetLayer( _nLayerNo );
     183           0 :                 OObjectBase& rBaseObj = dynamic_cast<OObjectBase&>(*pObj);
     184             :                 try
     185             :                 {
     186           0 :                     rBaseObj.getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::makeAny(_nLayerNo == RPT_LAYER_FRONT));
     187             :                 }
     188           0 :                 catch(const uno::Exception&)
     189             :                 {
     190             :                     DBG_UNHANDLED_EXCEPTION();
     191             :                 }
     192             :             }
     193             :         }
     194             : 
     195           0 :         EndUndo();
     196             : 
     197             :         // check mark list now instead of later in a timer
     198           0 :         CheckMarked();
     199           0 :         MarkListHasChanged();
     200             :     }
     201           0 : }
     202             : 
     203           0 : bool OSectionView::OnlyShapesMarked() const
     204             : {
     205           0 :     const SdrMarkList& rMark = GetMarkedObjectList();
     206           0 :     const size_t nCount = rMark.GetMarkCount();
     207           0 :     if ( !nCount )
     208           0 :         return false;
     209           0 :     for (size_t i = 0; i<nCount; ++i)
     210             :     {
     211           0 :         SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
     212           0 :         if ( !pObj->ISA(OCustomShape) )
     213             :         {
     214           0 :             return false;
     215             :         }
     216             :     }
     217           0 :     return true;
     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 ( size_t 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           6 : } // rptui
     258             : 
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10