LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/core/sdr - RptModel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 90 0.0 %
Date: 2012-12-27 Functions: 0 21 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 "RptModel.hxx"
      21             : #include "RptPage.hxx"
      22             : #include <dbaccess/dbsubcomponentcontroller.hxx>
      23             : #include <tools/debug.hxx>
      24             : #include <unotools/pathoptions.hxx>
      25             : 
      26             : #include "UndoActions.hxx"
      27             : #include "UndoEnv.hxx"
      28             : #include "ReportUndoFactory.hxx"
      29             : #include "ReportDefinition.hxx"
      30             : #define ITEMID_COLOR        1
      31             : #define ITEMID_BRUSH        2
      32             : #define ITEMID_FONT         3
      33             : #define ITEMID_FONTHEIGHT   4
      34             : 
      35             : #include <svx/tbcontrl.hxx>
      36             : #include "rptui_slotid.hrc"
      37             : #include "RptDef.hxx"
      38             : #include "corestrings.hrc"
      39             : #include "FixedLine.hxx"
      40             : #include "FormattedField.hxx"
      41             : #include "FixedText.hxx"
      42             : #include "ImageControl.hxx"
      43             : #include "Shape.hxx"
      44             : 
      45             : namespace rptui
      46             : {
      47             : using namespace reportdesign;
      48             : using namespace com::sun::star;
      49             : DBG_NAME( rpt_OReportModel )
      50           0 : TYPEINIT1(OReportModel,SdrModel);
      51             : 
      52             : //----------------------------------------------------------------------------
      53             : 
      54           0 : OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition) :
      55           0 :     SdrModel(SvtPathOptions().GetPalettePath(),NULL,_pReportDefinition)
      56             :     ,m_pController(NULL)
      57           0 :     ,m_pReportDefinition(_pReportDefinition)
      58             : {
      59             :     DBG_CTOR( rpt_OReportModel,0);
      60           0 :     SetAllowShapePropertyChangeListener(true);
      61           0 :     m_pUndoEnv = new OXUndoEnvironment(*this);
      62           0 :     m_pUndoEnv->acquire();
      63           0 :     SetSdrUndoFactory(new OReportUndoFactory);
      64           0 : }
      65             : 
      66             : //----------------------------------------------------------------------------
      67           0 : OReportModel::~OReportModel()
      68             : {
      69             :     DBG_DTOR( rpt_OReportModel,0);
      70           0 :     detachController();
      71           0 :     m_pUndoEnv->release();
      72           0 : }
      73             : // -----------------------------------------------------------------------------
      74           0 : void OReportModel::detachController()
      75             : {
      76           0 :     m_pReportDefinition = NULL;
      77           0 :     m_pController = NULL;
      78           0 :     m_pUndoEnv->EndListening( *this );
      79           0 :     ClearUndoBuffer();
      80           0 :     m_pUndoEnv->Clear(OXUndoEnvironment::Accessor());
      81           0 : }
      82             : //----------------------------------------------------------------------------
      83           0 : SdrPage* OReportModel::AllocPage(bool /*bMasterPage*/)
      84             : {
      85             :     DBG_CHKTHIS( rpt_OReportModel, 0);
      86             :     OSL_FAIL("Who called me!");
      87           0 :     return NULL;
      88             : }
      89             : 
      90             : //----------------------------------------------------------------------------
      91             : 
      92           0 : void OReportModel::SetChanged( sal_Bool bChanged )
      93             : {
      94           0 :     SdrModel::SetChanged( bChanged );
      95           0 :     SetModified( bChanged );
      96           0 : }
      97             : 
      98             : //----------------------------------------------------------------------------
      99             : 
     100           0 : Window* OReportModel::GetCurDocViewWin()
     101             : {
     102           0 :     return 0;
     103             : }
     104             : 
     105             : //----------------------------------------------------------------------------
     106           0 : OXUndoEnvironment&  OReportModel::GetUndoEnv()
     107             : {
     108           0 :     return *m_pUndoEnv;
     109             : }
     110             : //----------------------------------------------------------------------------
     111           0 : void OReportModel::SetModified(sal_Bool _bModified)
     112             : {
     113           0 :     if ( m_pController )
     114           0 :         m_pController->setModified(_bModified);
     115           0 : }
     116             : // -----------------------------------------------------------------------------
     117           0 : SdrPage* OReportModel::RemovePage(sal_uInt16 nPgNum)
     118             : {
     119           0 :     OReportPage* pPage = dynamic_cast<OReportPage*>(SdrModel::RemovePage(nPgNum));
     120           0 :     return pPage;
     121             : }
     122             : // -----------------------------------------------------------------------------
     123           0 : OReportPage* OReportModel::createNewPage(const uno::Reference< report::XSection >& _xSection)
     124             : {
     125           0 :     OReportPage* pPage = new OReportPage( *this ,_xSection);
     126           0 :     InsertPage(pPage);
     127           0 :     m_pUndoEnv->AddSection(_xSection);
     128           0 :     return pPage;
     129             : }
     130             : // -----------------------------------------------------------------------------
     131           0 : OReportPage* OReportModel::getPage(const uno::Reference< report::XSection >& _xSection)
     132             : {
     133           0 :     OReportPage* pPage = NULL;
     134           0 :     sal_uInt16 nCount = GetPageCount();
     135           0 :     for (sal_uInt16 i = 0; i < nCount && !pPage ; ++i)
     136             :     {
     137           0 :         OReportPage* pRptPage = PTR_CAST( OReportPage, GetPage(i) );
     138           0 :         if ( pRptPage && pRptPage->getSection() == _xSection )
     139           0 :             pPage = pRptPage;
     140             :     }
     141           0 :     return pPage;
     142             : }
     143             : // -----------------------------------------------------------------------------
     144           0 : SvxNumType OReportModel::GetPageNumType() const
     145             : {
     146           0 :     uno::Reference< report::XReportDefinition > xReportDefinition( getReportDefinition() );
     147           0 :     if ( xReportDefinition.is() )
     148           0 :         return (SvxNumType)getStyleProperty<sal_Int16>(xReportDefinition,reportdesign::PROPERTY_NUMBERINGTYPE);
     149           0 :     return SVX_ARABIC;
     150             : }
     151             : 
     152             : // -----------------------------------------------------------------------------
     153           0 : uno::Reference< report::XReportDefinition > OReportModel::getReportDefinition() const
     154             : {
     155           0 :     uno::Reference< report::XReportDefinition > xReportDefinition = m_pReportDefinition;
     156             :     OSL_ENSURE( xReportDefinition.is(), "OReportModel::getReportDefinition: invalid model at our controller!" );
     157           0 :     return xReportDefinition;
     158             : }
     159             : // -----------------------------------------------------------------------------
     160           0 : uno::Reference< uno::XInterface > OReportModel::createUnoModel()
     161             : {
     162           0 :     return uno::Reference< uno::XInterface >(getReportDefinition(),uno::UNO_QUERY);
     163             : }
     164             : // -----------------------------------------------------------------------------
     165           0 : uno::Reference< uno::XInterface > OReportModel::createShape(const ::rtl::OUString& aServiceSpecifier,uno::Reference< drawing::XShape >& _rShape,sal_Int32 nOrientation)
     166             : {
     167           0 :     uno::Reference< uno::XInterface > xRet;
     168           0 :     if ( _rShape.is() )
     169             :     {
     170           0 :         if ( aServiceSpecifier == SERVICE_FORMATTEDFIELD )
     171             :         {
     172           0 :             uno::Reference<report::XFormattedField> xProp = new OFormattedField(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape);
     173           0 :             xRet = xProp;
     174           0 :             if ( _rShape.is() )
     175           0 :                 throw uno::Exception();
     176           0 :             xProp->setPropertyValue( PROPERTY_FORMATSSUPPLIER, uno::makeAny(uno::Reference< util::XNumberFormatsSupplier >(*m_pReportDefinition,uno::UNO_QUERY)) );
     177             :         }
     178           0 :         else if ( aServiceSpecifier == SERVICE_FIXEDTEXT)
     179             :         {
     180           0 :             xRet = static_cast<cppu::OWeakObject*>(new OFixedText(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape));
     181           0 :             if ( _rShape.is() )
     182           0 :                 throw uno::Exception();
     183             :         }
     184           0 :         else if ( aServiceSpecifier == SERVICE_FIXEDLINE)
     185             :         {
     186           0 :             xRet = static_cast<cppu::OWeakObject*>(new OFixedLine(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape,nOrientation));
     187           0 :             if ( _rShape.is() )
     188           0 :                 throw uno::Exception();
     189             :         }
     190           0 :         else if ( aServiceSpecifier == SERVICE_IMAGECONTROL )
     191             :         {
     192           0 :             xRet = static_cast<cppu::OWeakObject*>(new OImageControl(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape));
     193           0 :             if ( _rShape.is() )
     194           0 :                 throw uno::Exception();
     195             :         }
     196           0 :         else if ( aServiceSpecifier == SERVICE_REPORTDEFINITION )
     197             :         {
     198           0 :             xRet = static_cast<cppu::OWeakObject*>(new OReportDefinition(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape));
     199           0 :             if ( _rShape.is() )
     200           0 :                 throw uno::Exception();
     201             :         }
     202           0 :         else if ( _rShape.is() )
     203             :         {
     204           0 :             xRet = static_cast<cppu::OWeakObject*>(new OShape(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape,aServiceSpecifier));
     205           0 :             if ( _rShape.is() )
     206           0 :                 throw uno::Exception();
     207             :         }
     208             :     }
     209           0 :     return xRet;
     210             : }
     211             : //==================================================================
     212             : }   //rptui
     213             : //==================================================================
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10