LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - RptModel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 90 0.0 %
Date: 2012-08-25 Functions: 0 21 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 192 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "RptModel.hxx"
      30                 :            : #include "RptPage.hxx"
      31                 :            : #include <dbaccess/dbsubcomponentcontroller.hxx>
      32                 :            : #include <tools/debug.hxx>
      33                 :            : #include <unotools/pathoptions.hxx>
      34                 :            : 
      35                 :            : #include "UndoActions.hxx"
      36                 :            : #include "UndoEnv.hxx"
      37                 :            : #include "ReportUndoFactory.hxx"
      38                 :            : #include "ReportDefinition.hxx"
      39                 :            : #define ITEMID_COLOR        1
      40                 :            : #define ITEMID_BRUSH        2
      41                 :            : #define ITEMID_FONT         3
      42                 :            : #define ITEMID_FONTHEIGHT   4
      43                 :            : 
      44                 :            : #include <svx/tbcontrl.hxx>
      45                 :            : #include "rptui_slotid.hrc"
      46                 :            : #include "RptDef.hxx"
      47                 :            : #include "corestrings.hrc"
      48                 :            : #include "FixedLine.hxx"
      49                 :            : #include "FormattedField.hxx"
      50                 :            : #include "FixedText.hxx"
      51                 :            : #include "ImageControl.hxx"
      52                 :            : #include "Shape.hxx"
      53                 :            : 
      54                 :            : namespace rptui
      55                 :            : {
      56                 :            : using namespace reportdesign;
      57                 :            : using namespace com::sun::star;
      58                 :            : DBG_NAME( rpt_OReportModel )
      59 [ #  # ][ #  # ]:          0 : TYPEINIT1(OReportModel,SdrModel);
      60                 :            : 
      61                 :            : //----------------------------------------------------------------------------
      62                 :            : 
      63                 :          0 : OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition) :
      64         [ #  # ]:          0 :     SdrModel(SvtPathOptions().GetPalettePath(),NULL,_pReportDefinition)
      65                 :            :     ,m_pController(NULL)
      66 [ #  # ][ #  # ]:          0 :     ,m_pReportDefinition(_pReportDefinition)
      67                 :            : {
      68                 :            :     DBG_CTOR( rpt_OReportModel,0);
      69         [ #  # ]:          0 :     SetAllowShapePropertyChangeListener(true);
      70         [ #  # ]:          0 :     m_pUndoEnv = new OXUndoEnvironment(*this);
      71                 :          0 :     m_pUndoEnv->acquire();
      72 [ #  # ][ #  # ]:          0 :     SetSdrUndoFactory(new OReportUndoFactory);
                 [ #  # ]
      73                 :          0 : }
      74                 :            : 
      75                 :            : //----------------------------------------------------------------------------
      76                 :          0 : OReportModel::~OReportModel()
      77                 :            : {
      78                 :            :     DBG_DTOR( rpt_OReportModel,0);
      79         [ #  # ]:          0 :     detachController();
      80                 :          0 :     m_pUndoEnv->release();
      81         [ #  # ]:          0 : }
      82                 :            : // -----------------------------------------------------------------------------
      83                 :          0 : void OReportModel::detachController()
      84                 :            : {
      85                 :          0 :     m_pReportDefinition = NULL;
      86                 :          0 :     m_pController = NULL;
      87                 :          0 :     m_pUndoEnv->EndListening( *this );
      88                 :          0 :     ClearUndoBuffer();
      89         [ #  # ]:          0 :     m_pUndoEnv->Clear(OXUndoEnvironment::Accessor());
      90                 :          0 : }
      91                 :            : //----------------------------------------------------------------------------
      92                 :          0 : SdrPage* OReportModel::AllocPage(bool /*bMasterPage*/)
      93                 :            : {
      94                 :            :     DBG_CHKTHIS( rpt_OReportModel, 0);
      95                 :            :     OSL_FAIL("Who called me!");
      96                 :          0 :     return NULL;
      97                 :            : }
      98                 :            : 
      99                 :            : //----------------------------------------------------------------------------
     100                 :            : 
     101                 :          0 : void OReportModel::SetChanged( sal_Bool bChanged )
     102                 :            : {
     103                 :          0 :     SdrModel::SetChanged( bChanged );
     104                 :          0 :     SetModified( bChanged );
     105                 :          0 : }
     106                 :            : 
     107                 :            : //----------------------------------------------------------------------------
     108                 :            : 
     109                 :          0 : Window* OReportModel::GetCurDocViewWin()
     110                 :            : {
     111                 :          0 :     return 0;
     112                 :            : }
     113                 :            : 
     114                 :            : //----------------------------------------------------------------------------
     115                 :          0 : OXUndoEnvironment&  OReportModel::GetUndoEnv()
     116                 :            : {
     117                 :          0 :     return *m_pUndoEnv;
     118                 :            : }
     119                 :            : //----------------------------------------------------------------------------
     120                 :          0 : void OReportModel::SetModified(sal_Bool _bModified)
     121                 :            : {
     122         [ #  # ]:          0 :     if ( m_pController )
     123                 :          0 :         m_pController->setModified(_bModified);
     124                 :          0 : }
     125                 :            : // -----------------------------------------------------------------------------
     126                 :          0 : SdrPage* OReportModel::RemovePage(sal_uInt16 nPgNum)
     127                 :            : {
     128         [ #  # ]:          0 :     OReportPage* pPage = dynamic_cast<OReportPage*>(SdrModel::RemovePage(nPgNum));
     129                 :          0 :     return pPage;
     130                 :            : }
     131                 :            : // -----------------------------------------------------------------------------
     132                 :          0 : OReportPage* OReportModel::createNewPage(const uno::Reference< report::XSection >& _xSection)
     133                 :            : {
     134         [ #  # ]:          0 :     OReportPage* pPage = new OReportPage( *this ,_xSection);
     135                 :          0 :     InsertPage(pPage);
     136                 :          0 :     m_pUndoEnv->AddSection(_xSection);
     137                 :          0 :     return pPage;
     138                 :            : }
     139                 :            : // -----------------------------------------------------------------------------
     140                 :          0 : OReportPage* OReportModel::getPage(const uno::Reference< report::XSection >& _xSection)
     141                 :            : {
     142                 :          0 :     OReportPage* pPage = NULL;
     143                 :          0 :     sal_uInt16 nCount = GetPageCount();
     144 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 i = 0; i < nCount && !pPage ; ++i)
                 [ #  # ]
     145                 :            :     {
     146 [ #  # ][ #  # ]:          0 :         OReportPage* pRptPage = PTR_CAST( OReportPage, GetPage(i) );
     147 [ #  # ][ #  # ]:          0 :         if ( pRptPage && pRptPage->getSection() == _xSection )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     148                 :          0 :             pPage = pRptPage;
     149                 :            :     }
     150                 :          0 :     return pPage;
     151                 :            : }
     152                 :            : // -----------------------------------------------------------------------------
     153                 :          0 : SvxNumType OReportModel::GetPageNumType() const
     154                 :            : {
     155         [ #  # ]:          0 :     uno::Reference< report::XReportDefinition > xReportDefinition( getReportDefinition() );
     156         [ #  # ]:          0 :     if ( xReportDefinition.is() )
     157 [ #  # ][ #  # ]:          0 :         return (SvxNumType)getStyleProperty<sal_Int16>(xReportDefinition,reportdesign::PROPERTY_NUMBERINGTYPE);
     158                 :          0 :     return SVX_ARABIC;
     159                 :            : }
     160                 :            : 
     161                 :            : // -----------------------------------------------------------------------------
     162                 :          0 : uno::Reference< report::XReportDefinition > OReportModel::getReportDefinition() const
     163                 :            : {
     164         [ #  # ]:          0 :     uno::Reference< report::XReportDefinition > xReportDefinition = m_pReportDefinition;
     165                 :            :     OSL_ENSURE( xReportDefinition.is(), "OReportModel::getReportDefinition: invalid model at our controller!" );
     166                 :          0 :     return xReportDefinition;
     167                 :            : }
     168                 :            : // -----------------------------------------------------------------------------
     169                 :          0 : uno::Reference< uno::XInterface > OReportModel::createUnoModel()
     170                 :            : {
     171         [ #  # ]:          0 :     return uno::Reference< uno::XInterface >(getReportDefinition(),uno::UNO_QUERY);
     172                 :            : }
     173                 :            : // -----------------------------------------------------------------------------
     174                 :          0 : uno::Reference< uno::XInterface > OReportModel::createShape(const ::rtl::OUString& aServiceSpecifier,uno::Reference< drawing::XShape >& _rShape,sal_Int32 nOrientation)
     175                 :            : {
     176                 :          0 :     uno::Reference< uno::XInterface > xRet;
     177         [ #  # ]:          0 :     if ( _rShape.is() )
     178                 :            :     {
     179 [ #  # ][ #  # ]:          0 :         if ( aServiceSpecifier == SERVICE_FORMATTEDFIELD )
     180                 :            :         {
     181 [ #  # ][ #  # ]:          0 :             uno::Reference<report::XFormattedField> xProp = new OFormattedField(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     182         [ #  # ]:          0 :             xRet = xProp;
     183         [ #  # ]:          0 :             if ( _rShape.is() )
     184         [ #  # ]:          0 :                 throw uno::Exception();
     185 [ #  # ][ #  # ]:          0 :             xProp->setPropertyValue( PROPERTY_FORMATSSUPPLIER, uno::makeAny(uno::Reference< util::XNumberFormatsSupplier >(*m_pReportDefinition,uno::UNO_QUERY)) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     186                 :            :         }
     187 [ #  # ][ #  # ]:          0 :         else if ( aServiceSpecifier == SERVICE_FIXEDTEXT)
     188                 :            :         {
     189 [ #  # ][ #  # ]:          0 :             xRet = static_cast<cppu::OWeakObject*>(new OFixedText(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape));
         [ #  # ][ #  # ]
                 [ #  # ]
     190         [ #  # ]:          0 :             if ( _rShape.is() )
     191         [ #  # ]:          0 :                 throw uno::Exception();
     192                 :            :         }
     193 [ #  # ][ #  # ]:          0 :         else if ( aServiceSpecifier == SERVICE_FIXEDLINE)
     194                 :            :         {
     195 [ #  # ][ #  # ]:          0 :             xRet = static_cast<cppu::OWeakObject*>(new OFixedLine(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape,nOrientation));
         [ #  # ][ #  # ]
                 [ #  # ]
     196         [ #  # ]:          0 :             if ( _rShape.is() )
     197         [ #  # ]:          0 :                 throw uno::Exception();
     198                 :            :         }
     199 [ #  # ][ #  # ]:          0 :         else if ( aServiceSpecifier == SERVICE_IMAGECONTROL )
     200                 :            :         {
     201 [ #  # ][ #  # ]:          0 :             xRet = static_cast<cppu::OWeakObject*>(new OImageControl(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape));
         [ #  # ][ #  # ]
                 [ #  # ]
     202         [ #  # ]:          0 :             if ( _rShape.is() )
     203         [ #  # ]:          0 :                 throw uno::Exception();
     204                 :            :         }
     205 [ #  # ][ #  # ]:          0 :         else if ( aServiceSpecifier == SERVICE_REPORTDEFINITION )
     206                 :            :         {
     207 [ #  # ][ #  # ]:          0 :             xRet = static_cast<cppu::OWeakObject*>(new OReportDefinition(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape));
         [ #  # ][ #  # ]
                 [ #  # ]
     208         [ #  # ]:          0 :             if ( _rShape.is() )
     209         [ #  # ]:          0 :                 throw uno::Exception();
     210                 :            :         }
     211         [ #  # ]:          0 :         else if ( _rShape.is() )
     212                 :            :         {
     213 [ #  # ][ #  # ]:          0 :             xRet = static_cast<cppu::OWeakObject*>(new OShape(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape,aServiceSpecifier));
         [ #  # ][ #  # ]
                 [ #  # ]
     214         [ #  # ]:          0 :             if ( _rShape.is() )
     215         [ #  # ]:          0 :                 throw uno::Exception();
     216                 :            :         }
     217                 :            :     }
     218                 :          0 :     return xRet;
     219                 :            : }
     220                 :            : //==================================================================
     221                 :            : }   //rptui
     222                 :            : //==================================================================
     223                 :            : 
     224                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10