LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - RptPage.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 89 0.0 %
Date: 2014-04-14 Functions: 0 19 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 "RptPage.hxx"
      20             : #include "RptModel.hxx"
      21             : #include "Section.hxx"
      22             : #include "RptObject.hxx"
      23             : #include <svx/unoapi.hxx>
      24             : #include <svx/unoshape.hxx>
      25             : #include "ReportDrawPage.hxx"
      26             : 
      27             : namespace rptui
      28             : {
      29             : using namespace ::com::sun::star;
      30           0 : TYPEINIT1( OReportPage, SdrPage );
      31             : 
      32             : 
      33           0 : OReportPage::OReportPage( OReportModel& _rModel
      34             :                          ,const uno::Reference< report::XSection >& _xSection
      35             :                          ,bool bMasterPage )
      36             :     :SdrPage( _rModel, bMasterPage )
      37             :     ,rModel(_rModel)
      38             :     ,m_xSection(_xSection)
      39           0 :      ,m_bSpecialInsertMode(false)
      40             : {
      41           0 : }
      42             : 
      43             : 
      44             : 
      45           0 : OReportPage::OReportPage( const OReportPage& rPage )
      46             :     :SdrPage( rPage )
      47             :     ,rModel(rPage.rModel)
      48             :      ,m_xSection(rPage.m_xSection)
      49             :      ,m_bSpecialInsertMode(rPage.m_bSpecialInsertMode)
      50           0 :      ,m_aTemporaryObjectList(rPage.m_aTemporaryObjectList)
      51             : {
      52           0 : }
      53             : 
      54             : 
      55             : 
      56           0 : OReportPage::~OReportPage()
      57             : {
      58           0 : }
      59             : 
      60             : 
      61             : 
      62           0 : SdrPage* OReportPage::Clone() const
      63             : {
      64           0 :     return new OReportPage( *this );
      65             : }
      66             : 
      67             : 
      68           0 : sal_uLong OReportPage::getIndexOf(const uno::Reference< report::XReportComponent >& _xObject)
      69             : {
      70           0 :     sal_uLong nCount = GetObjCount();
      71           0 :     sal_uLong i = 0;
      72           0 :     for (; i < nCount; ++i)
      73             :     {
      74           0 :         OObjectBase* pObj = dynamic_cast<OObjectBase*>(GetObj(i));
      75             :         OSL_ENSURE(pObj,"Invalid object found!");
      76           0 :         if ( pObj && pObj->getReportComponent() == _xObject )
      77             :         {
      78           0 :             break;
      79             :         }
      80             :     }
      81           0 :     return i;
      82             : }
      83             : 
      84           0 : void OReportPage::removeSdrObject(const uno::Reference< report::XReportComponent >& _xObject)
      85             : {
      86           0 :     sal_uLong nPos = getIndexOf(_xObject);
      87           0 :     if ( nPos < GetObjCount() )
      88             :     {
      89           0 :         OObjectBase* pBase = dynamic_cast<OObjectBase*>(GetObj(nPos));
      90             :         OSL_ENSURE(pBase,"Why is this not a OObjectBase?");
      91           0 :         if ( pBase )
      92           0 :             pBase->EndListening();
      93           0 :         RemoveObject(nPos);
      94             :     }
      95           0 : }
      96             : 
      97           0 : SdrObject* OReportPage::RemoveObject(sal_uLong nObjNum)
      98             : {
      99           0 :     SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
     100           0 :     if (getSpecialMode())
     101             :     {
     102           0 :         return pObj;
     103             :     }
     104             : 
     105             :     // this code is evil, but what else shall I do
     106           0 :     reportdesign::OSection* pSection = reportdesign::OSection::getImplementation(m_xSection);
     107           0 :     uno::Reference< drawing::XShape> xShape(pObj->getUnoShape(),uno::UNO_QUERY);
     108           0 :     pSection->notifyElementRemoved(xShape);
     109           0 :     if (pObj->ISA(OUnoObject))
     110             :     {
     111           0 :         OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObj);
     112           0 :         uno::Reference< container::XChild> xChild(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
     113           0 :         if ( xChild.is() )
     114           0 :             xChild->setParent(NULL);
     115             :     }
     116           0 :     return pObj;
     117             : }
     118             : 
     119           0 : void OReportPage::insertObject(const uno::Reference< report::XReportComponent >& _xObject)
     120             : {
     121             :     OSL_ENSURE(_xObject.is(),"Object is not valid to create a SdrObject!");
     122           0 :     if ( !_xObject.is() )
     123           0 :         return;
     124           0 :     sal_uLong nPos = getIndexOf(_xObject);
     125           0 :     if ( nPos < GetObjCount() )
     126           0 :         return; // Object already in list
     127             : 
     128           0 :     SvxShape* pShape = SvxShape::getImplementation( _xObject );
     129           0 :     OObjectBase* pObject = pShape ? dynamic_cast< OObjectBase* >( pShape->GetSdrObject() ) : NULL;
     130             :     OSL_ENSURE( pObject, "OReportPage::insertObject: no implementation object found for the given shape/component!" );
     131           0 :     if ( pObject )
     132           0 :         pObject->StartListening();
     133             : }
     134             : 
     135           0 : uno::Reference< report::XSection > OReportPage::getSection() const
     136             : {
     137           0 :     return m_xSection;
     138             : }
     139             : 
     140           0 : uno::Reference< uno::XInterface > OReportPage::createUnoPage()
     141             : {
     142           0 :     return static_cast<cppu::OWeakObject*>( new reportdesign::OReportDrawPage(this,m_xSection) );
     143             : }
     144             : 
     145           0 : void OReportPage::removeTempObject(SdrObject *_pToRemoveObj)
     146             : {
     147           0 :     if (_pToRemoveObj)
     148             :     {
     149           0 :         for (sal_uLong i=0;i<GetObjCount();i++)
     150             :         {
     151           0 :             SdrObject *aObj = GetObj(i);
     152           0 :             if (aObj && aObj == _pToRemoveObj)
     153             :             {
     154           0 :                 SdrObject* pObject = RemoveObject(i);
     155             :                 (void)pObject;
     156           0 :                 break;
     157             :             }
     158             :         }
     159             :     }
     160           0 : }
     161             : 
     162           0 : void OReportPage::resetSpecialMode()
     163             : {
     164           0 :     const sal_Bool bChanged = rModel.IsChanged();
     165           0 :     ::std::vector<SdrObject*>::iterator aIter = m_aTemporaryObjectList.begin();
     166           0 :     ::std::vector<SdrObject*>::iterator aEnd = m_aTemporaryObjectList.end();
     167             : 
     168           0 :     for (; aIter != aEnd; ++aIter)
     169             :     {
     170           0 :          removeTempObject(*aIter);
     171             :     }
     172           0 :     m_aTemporaryObjectList.clear();
     173           0 :     rModel.SetChanged(bChanged);
     174             : 
     175           0 :     m_bSpecialInsertMode = false;
     176           0 : }
     177             : 
     178           0 : void OReportPage::NbcInsertObject(SdrObject* pObj, sal_uLong nPos, const SdrInsertReason* pReason)
     179             : {
     180           0 :     SdrPage::NbcInsertObject(pObj, nPos, pReason);
     181             : 
     182           0 :     OUnoObject* pUnoObj = dynamic_cast< OUnoObject* >( pObj );
     183           0 :     if (getSpecialMode())
     184             :     {
     185           0 :         m_aTemporaryObjectList.push_back(pObj);
     186           0 :         return;
     187             :     }
     188             : 
     189           0 :     if ( pUnoObj )
     190             :     {
     191           0 :         pUnoObj->CreateMediator();
     192           0 :         uno::Reference< container::XChild> xChild(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
     193           0 :         if ( xChild.is() && !xChild->getParent().is() )
     194           0 :             xChild->setParent(m_xSection);
     195             :     }
     196             : 
     197             :     // this code is evil, but what else shall I do
     198           0 :     reportdesign::OSection* pSection = reportdesign::OSection::getImplementation(m_xSection);
     199           0 :     uno::Reference< drawing::XShape> xShape(pObj->getUnoShape(),uno::UNO_QUERY);
     200           0 :     pSection->notifyElementAdded(xShape);
     201             : 
     202             :     // now that the shape is inserted into its structures, we can allow the OObjectBase
     203             :     // to release the reference to it
     204           0 :     OObjectBase* pObjectBase = dynamic_cast< OObjectBase* >( pObj );
     205             :     OSL_ENSURE( pObjectBase, "OReportPage::NbcInsertObject: what is being inserted here?" );
     206           0 :     if ( pObjectBase )
     207           0 :         pObjectBase->releaseUnoShape();
     208             : }
     209             : 
     210             : } // rptui
     211             : 
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10