LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/core/api - Section.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 331 0.0 %
Date: 2012-12-27 Functions: 0 75 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 "Section.hxx"
      20             : #include <comphelper/enumhelper.hxx>
      21             : #include <connectivity/dbtools.hxx>
      22             : #include <com/sun/star/report/XReportComponent.hpp>
      23             : #include <com/sun/star/report/ForceNewPage.hpp>
      24             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      25             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26             : #include "corestrings.hrc"
      27             : #include "core_resource.hxx"
      28             : #include "core_resource.hrc"
      29             : #include <tools/debug.hxx>
      30             : #include "Tools.hxx"
      31             : #include "RptModel.hxx"
      32             : #include "RptPage.hxx"
      33             : #include "ReportDefinition.hxx"
      34             : #include "Shape.hxx"
      35             : #include <svx/unoshape.hxx>
      36             : #include "RptObject.hxx"
      37             : #include "ReportDrawPage.hxx"
      38             : #include <comphelper/property.hxx>
      39             : // =============================================================================
      40             : namespace reportdesign
      41             : {
      42             : // =============================================================================
      43             :     using namespace com::sun::star;
      44             :     using namespace comphelper;
      45             : DBG_NAME( rpt_OSection )
      46             : 
      47             : // -----------------------------------------------------------------------------
      48           0 : uno::Sequence< ::rtl::OUString> lcl_getGroupAbsent()
      49             : {
      50             :     ::rtl::OUString pProps[] = {
      51             :                 PROPERTY_CANGROW
      52             :                 ,PROPERTY_CANSHRINK
      53           0 :         };
      54             : 
      55           0 :     return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
      56             : }
      57             : 
      58             : // -----------------------------------------------------------------------------
      59           0 : uno::Sequence< ::rtl::OUString> lcl_getAbsent(bool _bPageSection)
      60             : {
      61           0 :     if ( _bPageSection )
      62             :     {
      63             :         ::rtl::OUString pProps[] = {
      64             :                 PROPERTY_FORCENEWPAGE
      65             :                 ,PROPERTY_NEWROWORCOL
      66             :                 ,PROPERTY_KEEPTOGETHER
      67             :                 ,PROPERTY_CANGROW
      68             :                 ,PROPERTY_CANSHRINK
      69             :                 ,PROPERTY_REPEATSECTION
      70           0 :         };
      71           0 :         return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
      72             :     }
      73             : 
      74             :     ::rtl::OUString pProps[] = {
      75             :                 PROPERTY_CANGROW
      76             :                 ,PROPERTY_CANSHRINK
      77             :                 ,PROPERTY_REPEATSECTION
      78           0 :         };
      79             : 
      80           0 :     return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
      81             : }
      82             : 
      83           0 : uno::Reference<report::XSection> OSection::createOSection(
      84             :     const uno::Reference< report::XReportDefinition >& xParentDef,
      85             :     const uno::Reference< uno::XComponentContext >& context,
      86             :     bool const bPageSection)
      87             : {
      88             :     OSection *const pNew =
      89           0 :         new OSection(xParentDef, 0, context, lcl_getAbsent(bPageSection));
      90           0 :     pNew->init();
      91           0 :     return pNew;
      92             : }
      93             : 
      94           0 : uno::Reference<report::XSection> OSection::createOSection(
      95             :     const uno::Reference< report::XGroup >& xParentGroup,
      96             :     const uno::Reference< uno::XComponentContext >& context,
      97             :     bool const)
      98             : {
      99             :     OSection *const pNew =
     100           0 :         new OSection(0, xParentGroup, context, lcl_getGroupAbsent());
     101           0 :     pNew->init();
     102           0 :     return pNew;
     103             : }
     104             : 
     105             : // -----------------------------------------------------------------------------
     106           0 : OSection::OSection(const uno::Reference< report::XReportDefinition >& xParentDef
     107             :                    ,const uno::Reference< report::XGroup >& xParentGroup
     108             :                    ,const uno::Reference< uno::XComponentContext >& context
     109             :                    ,uno::Sequence< ::rtl::OUString> const& rStrings)
     110             : :SectionBase(m_aMutex)
     111             : ,SectionPropertySet(context,SectionPropertySet::IMPLEMENTS_PROPERTY_SET,rStrings)
     112             : ,m_aContainerListeners(m_aMutex)
     113             : ,m_xContext(context)
     114             : ,m_xGroup(xParentGroup)
     115             : ,m_xReportDefinition(xParentDef)
     116             : ,m_nHeight(3000)
     117             : ,m_nBackgroundColor(COL_TRANSPARENT)
     118             : ,m_nForceNewPage(report::ForceNewPage::NONE)
     119             : ,m_nNewRowOrCol(report::ForceNewPage::NONE)
     120             : ,m_bKeepTogether(sal_False)
     121             : ,m_bCanGrow(sal_False)
     122             : ,m_bCanShrink(sal_False)
     123             : ,m_bRepeatSection(sal_False)
     124             : ,m_bVisible(sal_True)
     125             : ,m_bBacktransparent(sal_True)
     126             : ,m_bInRemoveNotify(false)
     127           0 : ,m_bInInsertNotify(false)
     128             : {
     129             :     DBG_CTOR( rpt_OSection,NULL);
     130           0 : }
     131             : //--------------------------------------------------------------------------
     132             : // TODO: VirtualFunctionFinder: This is virtual function!
     133             : //
     134           0 : OSection::~OSection()
     135             : {
     136             :     DBG_DTOR( rpt_OSection,NULL);
     137           0 : }
     138             : //--------------------------------------------------------------------------
     139             : //IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet)
     140           0 : IMPLEMENT_FORWARD_REFCOUNT( OSection, SectionBase )
     141             : // --------------------------------------------------------------------------------
     142           0 : uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
     143             : {
     144           0 :     uno::Any aReturn = SectionBase::queryInterface(_rType);
     145           0 :     if ( !aReturn.hasValue() )
     146           0 :         aReturn = SectionPropertySet::queryInterface(_rType);
     147             : 
     148           0 :     if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
     149           0 :         return aReturn;
     150             : 
     151           0 :     return aReturn;
     152             : }
     153             : 
     154             : // -----------------------------------------------------------------------------
     155           0 : void SAL_CALL OSection::dispose() throw(uno::RuntimeException)
     156             : {
     157             :     OSL_ENSURE(!rBHelper.bDisposed,"Already disposed!");
     158           0 :     SectionPropertySet::dispose();
     159             :     uno::Reference<lang::XComponent> const xPageComponent(m_xDrawPage,
     160           0 :             uno::UNO_QUERY);
     161           0 :     if (xPageComponent.is())
     162             :     {
     163           0 :         xPageComponent->dispose();
     164             :     }
     165           0 :     cppu::WeakComponentImplHelperBase::dispose();
     166             : 
     167           0 : }
     168             : // -----------------------------------------------------------------------------
     169             : // TODO: VirtualFunctionFinder: This is virtual function!
     170             : //
     171           0 : void SAL_CALL OSection::disposing()
     172             : {
     173           0 :     lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) );
     174           0 :     m_aContainerListeners.disposeAndClear( aDisposeEvent );
     175           0 :     m_xContext.clear();
     176           0 : }
     177             : //--------------------------------------------------------------------------
     178           0 : ::rtl::OUString SAL_CALL OSection::getImplementationName(  ) throw(uno::RuntimeException)
     179             : {
     180           0 :     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Section"));
     181             : }
     182             : //------------------------------------------------------------------------------
     183           0 : uno::Sequence< ::rtl::OUString> OSection::getSupportedServiceNames_Static(void) throw( uno::RuntimeException )
     184             : {
     185           0 :     uno::Sequence< ::rtl::OUString> aSupported(1);
     186           0 :     aSupported.getArray()[0] = SERVICE_SECTION;
     187           0 :     return aSupported;
     188             : }
     189             : //-------------------------------------------------------------------------
     190           0 : uno::Sequence< ::rtl::OUString> SAL_CALL OSection::getSupportedServiceNames() throw(uno::RuntimeException)
     191             : {
     192           0 :     return getSupportedServiceNames_Static();
     193             : }
     194             : // -----------------------------------------------------------------------------
     195           0 : sal_Bool SAL_CALL OSection::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
     196             : {
     197           0 :     return ::comphelper::existsValue(_rServiceName,getSupportedServiceNames_Static());
     198             : }
     199             : // -----------------------------------------------------------------------------
     200           0 : void OSection::init()
     201             : {
     202           0 :     uno::Reference< report::XReportDefinition> xReport = getReportDefinition();
     203           0 :     ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport);
     204             :     assert(pModel); //"No model set at the report definition!"
     205           0 :     if ( pModel )
     206             :     {
     207           0 :         uno::Reference<report::XSection> const xSection(this);
     208           0 :         SdrPage & rSdrPage(*pModel->createNewPage(xSection));
     209           0 :         m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW);
     210           0 :         m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW);
     211             :         // apparently we may also get OReportDrawPage which doesn't support this
     212           0 :         m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY);
     213           0 :         m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW);
     214             :         // fdo#53872: now also exchange the XDrawPage in the SdrPage so that
     215             :         // rSdrPage.getUnoPage returns this
     216           0 :         rSdrPage.SetUnoPage(this);
     217             :         // createNewPage _should_ have stored away 2 uno::References to this,
     218             :         // so our ref count cannot be 1 here, so this isn't destroyed here
     219           0 :         assert(m_refCount > 1);
     220           0 :     }
     221           0 : }
     222             : // -----------------------------------------------------------------------------
     223             : // XSection
     224             : // -----------------------------------------------------------------------------
     225           0 : ::sal_Bool SAL_CALL OSection::getVisible() throw (uno::RuntimeException)
     226             : {
     227           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     228           0 :     return m_bVisible;
     229             : }
     230             : // -----------------------------------------------------------------------------
     231           0 : void SAL_CALL OSection::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
     232             : {
     233           0 :     set(PROPERTY_VISIBLE,_visible,m_bVisible);
     234           0 : }
     235             : // -----------------------------------------------------------------------------
     236           0 : ::rtl::OUString SAL_CALL OSection::getName() throw (uno::RuntimeException)
     237             : {
     238           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     239           0 :     return m_sName;
     240             : }
     241             : // -----------------------------------------------------------------------------
     242           0 : void SAL_CALL OSection::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException)
     243             : {
     244           0 :     set(PROPERTY_NAME,_name,m_sName);
     245           0 : }
     246             : // -----------------------------------------------------------------------------
     247           0 : ::sal_uInt32 SAL_CALL OSection::getHeight() throw (uno::RuntimeException)
     248             : {
     249           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     250           0 :     return m_nHeight;
     251             : }
     252             : // -----------------------------------------------------------------------------
     253           0 : void SAL_CALL OSection::setHeight( ::sal_uInt32 _height ) throw (uno::RuntimeException)
     254             : {
     255           0 :     set(PROPERTY_HEIGHT,_height,m_nHeight);
     256           0 : }
     257             : // -----------------------------------------------------------------------------
     258           0 : ::sal_Int32 SAL_CALL OSection::getBackColor() throw (uno::RuntimeException)
     259             : {
     260           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     261           0 :     return m_bBacktransparent ? COL_TRANSPARENT : m_nBackgroundColor;
     262             : }
     263             : // -----------------------------------------------------------------------------
     264           0 : void SAL_CALL OSection::setBackColor( ::sal_Int32 _backgroundcolor ) throw (uno::RuntimeException)
     265             : {
     266           0 :     sal_Bool bTransparent = _backgroundcolor == static_cast<sal_Int32>(COL_TRANSPARENT);
     267           0 :     setBackTransparent(bTransparent);
     268           0 :     if ( !bTransparent )
     269           0 :         set(PROPERTY_BACKCOLOR,_backgroundcolor,m_nBackgroundColor);
     270           0 : }
     271             : // -----------------------------------------------------------------------------
     272           0 : ::sal_Bool SAL_CALL OSection::getBackTransparent() throw (uno::RuntimeException)
     273             : {
     274           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     275           0 :     return m_bBacktransparent;
     276             : }
     277             : // -----------------------------------------------------------------------------
     278           0 : void SAL_CALL OSection::setBackTransparent( ::sal_Bool _backtransparent ) throw (uno::RuntimeException)
     279             : {
     280           0 :     set(PROPERTY_BACKTRANSPARENT,_backtransparent,m_bBacktransparent);
     281           0 :     if ( _backtransparent )
     282           0 :         set(PROPERTY_BACKCOLOR,static_cast<sal_Int32>(COL_TRANSPARENT),m_nBackgroundColor);
     283           0 : }
     284             : // -----------------------------------------------------------------------------
     285           0 : ::rtl::OUString SAL_CALL OSection::getConditionalPrintExpression() throw (uno::RuntimeException)
     286             : {
     287           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     288           0 :     return m_sConditionalPrintExpression;
     289             : }
     290             : // -----------------------------------------------------------------------------
     291           0 : void SAL_CALL OSection::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (uno::RuntimeException)
     292             : {
     293           0 :     set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_sConditionalPrintExpression);
     294           0 : }
     295             : // -----------------------------------------------------------------------------
     296           0 : void OSection::checkNotPageHeaderFooter()
     297             : {
     298           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     299           0 :     uno::Reference< report::XReportDefinition > xRet = m_xReportDefinition;
     300           0 :     if ( xRet.is() )
     301             :     {
     302           0 :         if ( xRet->getPageHeaderOn() && xRet->getPageHeader() == *this )
     303           0 :             throw beans::UnknownPropertyException();
     304           0 :         if ( xRet->getPageFooterOn() && xRet->getPageFooter() == *this )
     305           0 :             throw beans::UnknownPropertyException();
     306           0 :     }
     307           0 : }
     308             : // -----------------------------------------------------------------------------
     309           0 : ::sal_Int16 SAL_CALL OSection::getForceNewPage() throw (beans::UnknownPropertyException, uno::RuntimeException)
     310             : {
     311           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     312             : 
     313           0 :     checkNotPageHeaderFooter();
     314           0 :     return m_nForceNewPage;
     315             : }
     316             : // -----------------------------------------------------------------------------
     317           0 : void SAL_CALL OSection::setForceNewPage( ::sal_Int16 _forcenewpage ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
     318             : {
     319           0 :     if ( _forcenewpage < report::ForceNewPage::NONE || _forcenewpage > report::ForceNewPage::BEFORE_AFTER_SECTION )
     320             :         throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage"))
     321             :                         ,*this
     322             :                         ,1
     323           0 :                         ,m_xContext);
     324           0 :     checkNotPageHeaderFooter();
     325           0 :     set(PROPERTY_FORCENEWPAGE,_forcenewpage,m_nForceNewPage);
     326           0 : }
     327             : // -----------------------------------------------------------------------------
     328           0 : ::sal_Int16 SAL_CALL OSection::getNewRowOrCol() throw (beans::UnknownPropertyException, uno::RuntimeException)
     329             : {
     330           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     331           0 :     checkNotPageHeaderFooter();
     332           0 :     return m_nNewRowOrCol;
     333             : }
     334             : // -----------------------------------------------------------------------------
     335           0 : void SAL_CALL OSection::setNewRowOrCol( ::sal_Int16 _newroworcol ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
     336             : {
     337           0 :     if ( _newroworcol < report::ForceNewPage::NONE || _newroworcol > report::ForceNewPage::BEFORE_AFTER_SECTION )
     338             :         throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage"))
     339             :                         ,*this
     340             :                         ,1
     341           0 :                         ,m_xContext);
     342           0 :     checkNotPageHeaderFooter();
     343             : 
     344           0 :     set(PROPERTY_NEWROWORCOL,_newroworcol,m_nNewRowOrCol);
     345           0 : }
     346             : // -----------------------------------------------------------------------------
     347           0 : ::sal_Bool SAL_CALL OSection::getKeepTogether() throw (beans::UnknownPropertyException, uno::RuntimeException)
     348             : {
     349           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     350           0 :     checkNotPageHeaderFooter();
     351           0 :     return m_bKeepTogether;
     352             : }
     353             : // -----------------------------------------------------------------------------
     354           0 : void SAL_CALL OSection::setKeepTogether( ::sal_Bool _keeptogether ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
     355             : {
     356             :     {
     357           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     358           0 :         checkNotPageHeaderFooter();
     359             :     }
     360             : 
     361           0 :     set(PROPERTY_KEEPTOGETHER,_keeptogether,m_bKeepTogether);
     362           0 : }
     363             : // -----------------------------------------------------------------------------
     364           0 : ::sal_Bool SAL_CALL OSection::getCanGrow() throw (beans::UnknownPropertyException, uno::RuntimeException)
     365             : {
     366           0 :     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
     367             : }
     368             : // -----------------------------------------------------------------------------
     369           0 : void SAL_CALL OSection::setCanGrow( ::sal_Bool /*_cangrow*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
     370             : {
     371           0 :     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
     372             : }
     373             : // -----------------------------------------------------------------------------
     374           0 : ::sal_Bool SAL_CALL OSection::getCanShrink() throw (beans::UnknownPropertyException, uno::RuntimeException)
     375             : {
     376           0 :     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
     377             : }
     378             : // -----------------------------------------------------------------------------
     379           0 : void SAL_CALL OSection::setCanShrink( ::sal_Bool /*_canshrink*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
     380             : {
     381           0 :     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
     382             : }
     383             : // -----------------------------------------------------------------------------
     384           0 : ::sal_Bool SAL_CALL OSection::getRepeatSection() throw (beans::UnknownPropertyException, uno::RuntimeException)
     385             : {
     386           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     387           0 :     uno::Reference< report::XGroup > xGroup = m_xGroup;
     388           0 :     if ( !xGroup.is() )
     389           0 :         throw beans::UnknownPropertyException();
     390           0 :     return m_bRepeatSection;
     391             : }
     392             : // -----------------------------------------------------------------------------
     393           0 : void SAL_CALL OSection::setRepeatSection( ::sal_Bool _repeatsection ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
     394             : {
     395             :     {
     396           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     397           0 :         uno::Reference< report::XGroup > xGroup = m_xGroup;
     398           0 :         if ( !xGroup.is() )
     399           0 :             throw beans::UnknownPropertyException();
     400             :     }
     401           0 :     set(PROPERTY_REPEATSECTION,_repeatsection,m_bRepeatSection);
     402           0 : }
     403             : // -----------------------------------------------------------------------------
     404           0 : uno::Reference< report::XGroup > SAL_CALL OSection::getGroup() throw (uno::RuntimeException)
     405             : {
     406           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     407           0 :     return m_xGroup;
     408             : }
     409             : // -----------------------------------------------------------------------------
     410           0 : uno::Reference< report::XReportDefinition > SAL_CALL OSection::getReportDefinition() throw (uno::RuntimeException)
     411             : {
     412           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     413           0 :     uno::Reference< report::XReportDefinition > xRet = m_xReportDefinition;
     414           0 :     uno::Reference< report::XGroup > xGroup = m_xGroup;
     415           0 :     if ( !xRet.is() && xGroup.is() )
     416             :     {
     417           0 :         uno::Reference< report::XGroups> xGroups(xGroup->getGroups());
     418           0 :         if ( xGroups.is() )
     419           0 :             xRet = xGroups->getReportDefinition();
     420             :     }
     421             : 
     422           0 :     return xRet;
     423             : }
     424             : // -----------------------------------------------------------------------------
     425           0 : const ::std::vector< ::rtl::OUString >& lcl_getControlModelMap()
     426             : {
     427           0 :     static ::std::vector< ::rtl::OUString > s_sControlModels;
     428           0 :     if ( s_sControlModels.empty() )
     429             :     {
     430           0 :         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedText")) );
     431           0 :         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedLine")) );
     432           0 :         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageControl")) );
     433           0 :         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormattedField")) );
     434           0 :         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shape")) );
     435             :     }
     436           0 :     return s_sControlModels;
     437             : 
     438             : }
     439             : // -----------------------------------------------------------------------------
     440           0 : uno::Reference< report::XReportComponent > SAL_CALL OSection::createReportComponent( const ::rtl::OUString& _sReportComponentSpecifier ) throw (uno::Exception, lang::IllegalArgumentException,uno::RuntimeException)
     441             : {
     442           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
     443           0 :     const ::std::vector< ::rtl::OUString >& aRet = lcl_getControlModelMap();
     444           0 :     ::std::vector< ::rtl::OUString >::const_iterator aFind = ::std::find(aRet.begin(),aRet.end(),_sReportComponentSpecifier);
     445           0 :     if ( aFind == aRet.end() )
     446           0 :         throw lang::IllegalArgumentException();
     447             : 
     448           0 :     uno::Reference< report::XReportComponent > xRet;
     449           0 :     uno::Reference< lang::XMultiServiceFactory> xFac(getReportDefinition(),uno::UNO_QUERY_THROW);
     450           0 :     switch( aFind - aRet.begin()  )
     451             :     {
     452             :         case 0:
     453           0 :             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))),uno::UNO_QUERY);
     454           0 :             break;
     455             :         case 1:
     456           0 :             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))),uno::UNO_QUERY);
     457           0 :             break;
     458             :         case 2:
     459           0 :             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))),uno::UNO_QUERY);
     460           0 :             break;
     461             :         case 3:
     462           0 :             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))),uno::UNO_QUERY);
     463           0 :             break;
     464             :         case 4:
     465           0 :             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape"))),uno::UNO_QUERY);
     466           0 :             break;
     467             :         default:
     468           0 :             break;
     469             :     }
     470           0 :     return xRet;
     471             : }
     472             : // -----------------------------------------------------------------------------
     473           0 : uno::Sequence< ::rtl::OUString > SAL_CALL OSection::getAvailableReportComponentNames(  ) throw (uno::RuntimeException)
     474             : {
     475           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     476             : 
     477           0 :     const ::std::vector< ::rtl::OUString >& aRet = lcl_getControlModelMap();
     478           0 :     const ::rtl::OUString* pRet = aRet.empty() ? 0 : &aRet[0];
     479           0 :     return uno::Sequence< ::rtl::OUString >(pRet, aRet.size());
     480             : }
     481             : // -----------------------------------------------------------------------------
     482             : // XChild
     483           0 : uno::Reference< uno::XInterface > SAL_CALL OSection::getParent(  ) throw (uno::RuntimeException)
     484             : {
     485           0 :     uno::Reference< uno::XInterface > xRet;
     486             :     {
     487           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     488           0 :         xRet = m_xReportDefinition;
     489           0 :         if ( !xRet.is() )
     490           0 :             xRet = m_xGroup;
     491             :     }
     492           0 :     return  xRet;
     493             : }
     494             : // -----------------------------------------------------------------------------
     495           0 : void SAL_CALL OSection::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException)
     496             : {
     497           0 :     throw lang::NoSupportException();
     498             : }
     499             : // -----------------------------------------------------------------------------
     500             : // XContainer
     501           0 : void SAL_CALL OSection::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
     502             : {
     503           0 :     m_aContainerListeners.addInterface(xListener);
     504           0 : }
     505             : // -----------------------------------------------------------------------------
     506           0 : void SAL_CALL OSection::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
     507             : {
     508           0 :     m_aContainerListeners.removeInterface(xListener);
     509           0 : }
     510             : // -----------------------------------------------------------------------------
     511             : // XElementAccess
     512           0 : uno::Type SAL_CALL OSection::getElementType(  ) throw (uno::RuntimeException)
     513             : {
     514           0 :     return ::getCppuType(static_cast< uno::Reference<report::XReportComponent>*>(NULL));
     515             : }
     516             : // -----------------------------------------------------------------------------
     517           0 : ::sal_Bool SAL_CALL OSection::hasElements(  ) throw (uno::RuntimeException)
     518             : {
     519           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     520           0 :     return m_xDrawPage.is() ? m_xDrawPage->hasElements() : sal_False;
     521             : }
     522             : // -----------------------------------------------------------------------------
     523             : // XIndexAccess
     524           0 : ::sal_Int32 SAL_CALL OSection::getCount(  ) throw (uno::RuntimeException)
     525             : {
     526           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     527           0 :     return m_xDrawPage.is() ? m_xDrawPage->getCount() : 0;
     528             : }
     529             : // -----------------------------------------------------------------------------
     530           0 : uno::Any SAL_CALL OSection::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     531             : {
     532           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     533           0 :     return m_xDrawPage.is() ? m_xDrawPage->getByIndex(Index) : uno::Any();
     534             : }
     535             : // -----------------------------------------------------------------------------
     536             : // XEnumerationAccess
     537           0 : uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration(  ) throw (uno::RuntimeException)
     538             : {
     539           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     540           0 :     return new ::comphelper::OEnumerationByIndex(static_cast<XSection*>(this));
     541             : }
     542             : // -----------------------------------------------------------------------------
     543           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL OSection::getPropertySetInfo(  ) throw(uno::RuntimeException)
     544             : {
     545           0 :     return SectionPropertySet::getPropertySetInfo();
     546             : }
     547             : // -------------------------------------------------------------------------
     548           0 : void SAL_CALL OSection::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     549             : {
     550           0 :     SectionPropertySet::setPropertyValue( aPropertyName, aValue );
     551           0 : }
     552             : // -----------------------------------------------------------------------------
     553           0 : uno::Any SAL_CALL OSection::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     554             : {
     555           0 :     return SectionPropertySet::getPropertyValue( PropertyName);
     556             : }
     557             : // -----------------------------------------------------------------------------
     558           0 : void SAL_CALL OSection::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     559             : {
     560           0 :     SectionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
     561           0 : }
     562             : // -----------------------------------------------------------------------------
     563           0 : void SAL_CALL OSection::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     564             : {
     565           0 :     SectionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
     566           0 : }
     567             : // -----------------------------------------------------------------------------
     568           0 : void SAL_CALL OSection::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     569             : {
     570           0 :     SectionPropertySet::addVetoableChangeListener( PropertyName, aListener );
     571           0 : }
     572             : // -----------------------------------------------------------------------------
     573           0 : void SAL_CALL OSection::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     574             : {
     575           0 :     SectionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
     576           0 : }
     577             : // -----------------------------------------------------------------------------
     578           0 : void OSection::lcl_copySection(const uno::Reference< report::XSection>& _xSource,uno::Reference< report::XSection>& _xDest)
     579             : {
     580           0 :     if ( _xSource.is() )
     581             :     {
     582           0 :         ::comphelper::copyProperties(_xSource.get(),_xDest.get());
     583           0 :         sal_Int32 nCount = _xSource->getCount();
     584           0 :         for(sal_Int32 i = 0;i != nCount;++i)
     585             :         {
     586           0 :             uno::Reference<util::XCloneable> xClone(_xSource->getByIndex(i),uno::UNO_QUERY);
     587             :             OSL_ENSURE(xClone.is(),"No XCloneable interface found!");
     588           0 :             if ( xClone.is() )
     589             :             {
     590           0 :                 uno::Reference< drawing::XShape> xShape(xClone->createClone(),uno::UNO_QUERY);
     591           0 :                 _xDest->add(xShape);
     592             :             }
     593           0 :         }
     594             :     }
     595           0 : }
     596             : // -----------------------------------------------------------------------------
     597           0 : void SAL_CALL OSection::add( const uno::Reference< drawing::XShape >& xShape ) throw (uno::RuntimeException)
     598             : {
     599             :     {
     600           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     601           0 :         m_bInInsertNotify = true;
     602             :         OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!");
     603           0 :         m_xDrawPage->add(xShape);
     604           0 :         m_bInInsertNotify = false;
     605             :     }
     606           0 :     notifyElementAdded(xShape);
     607           0 : }
     608             : // -----------------------------------------------------------------------------
     609           0 : void SAL_CALL OSection::remove( const uno::Reference< drawing::XShape >& xShape ) throw (uno::RuntimeException)
     610             : {
     611             :     {
     612           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     613           0 :         m_bInRemoveNotify = true;
     614             :         OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!");
     615           0 :         m_xDrawPage->remove(xShape);
     616           0 :         m_bInRemoveNotify = false;
     617             :     }
     618           0 :     notifyElementRemoved(xShape);
     619           0 : }
     620             : 
     621             : // XShapeGrouper
     622             : uno::Reference< drawing::XShapeGroup > SAL_CALL
     623           0 : OSection::group(uno::Reference< drawing::XShapes > const& xShapes)
     624             :     throw (uno::RuntimeException)
     625             : {
     626             :     // no lock because m_xDrawPage_ShapeGrouper is const
     627           0 :     return (m_xDrawPage_ShapeGrouper.is())
     628           0 :         ? m_xDrawPage_ShapeGrouper->group(xShapes)
     629           0 :         : 0;
     630             : }
     631             : void SAL_CALL
     632           0 : OSection::ungroup(uno::Reference<drawing::XShapeGroup> const& xGroup)
     633             :     throw (uno::RuntimeException)
     634             : {
     635             :     // no lock because m_xDrawPage_ShapeGrouper is const
     636           0 :     if (m_xDrawPage_ShapeGrouper.is()) {
     637           0 :         m_xDrawPage_ShapeGrouper->ungroup(xGroup);
     638             :     }
     639           0 : }
     640             : 
     641             : // XFormsSupplier
     642           0 : uno::Reference<container::XNameContainer> SAL_CALL OSection::getForms()
     643             :     throw (uno::RuntimeException)
     644             : {
     645             :     // no lock because m_xDrawPage_FormSupplier is const
     646           0 :     return (m_xDrawPage_FormSupplier.is())
     647           0 :         ? m_xDrawPage_FormSupplier->getForms()
     648           0 :         : 0;
     649             : }
     650             : // XFormsSupplier2
     651           0 : sal_Bool SAL_CALL OSection::hasForms() throw (uno::RuntimeException)
     652             : {
     653             :     // no lock because m_xDrawPage_FormSupplier is const
     654           0 :     return (m_xDrawPage_FormSupplier.is())
     655           0 :         ? m_xDrawPage_FormSupplier->hasForms()
     656           0 :         : 0;
     657             : }
     658             : 
     659             : // -----------------------------------------------------------------------------
     660             : // com::sun::star::lang::XUnoTunnel
     661             : //------------------------------------------------------------------
     662           0 : sal_Int64 OSection::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw (uno::RuntimeException)
     663             : {
     664           0 :     if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
     665           0 :         return reinterpret_cast<sal_Int64>(this);
     666           0 :     return (m_xDrawPage_Tunnel.is()) ? m_xDrawPage_Tunnel->getSomething(rId) : 0;
     667             : }
     668             : 
     669             : // -----------------------------------------------------------------------------
     670           0 : OSection* OSection::getImplementation( const uno::Reference< uno::XInterface >& _rxComponent )
     671             : {
     672           0 :     OSection* pContent( NULL );
     673             : 
     674           0 :     uno::Reference< lang::XUnoTunnel > xUnoTunnel( _rxComponent, uno::UNO_QUERY );
     675           0 :     if ( xUnoTunnel.is() )
     676           0 :         pContent = reinterpret_cast< OSection* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
     677             : 
     678           0 :     return pContent;
     679             : }
     680             : //------------------------------------------------------------------------
     681           0 : uno::Sequence< sal_Int8 > OSection::getUnoTunnelImplementationId()
     682             : {
     683             :     static ::cppu::OImplementationId * pId = 0;
     684           0 :     if (! pId)
     685             :     {
     686           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     687           0 :         if (! pId)
     688             :         {
     689           0 :             static ::cppu::OImplementationId aId;
     690           0 :             pId = &aId;
     691           0 :         }
     692             :     }
     693           0 :     return pId->getImplementationId();
     694             : }
     695             : // -----------------------------------------------------------------------------
     696           0 : void OSection::notifyElementAdded(const uno::Reference< drawing::XShape >& xShape )
     697             : {
     698           0 :     if ( !m_bInInsertNotify )
     699             :     {
     700           0 :         container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::Any(), uno::makeAny(xShape), uno::Any());
     701           0 :         m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent);
     702             :     }
     703           0 : }
     704             : // -----------------------------------------------------------------------------
     705           0 : void OSection::notifyElementRemoved(const uno::Reference< drawing::XShape >& xShape)
     706             : {
     707           0 :     if ( !m_bInRemoveNotify )
     708             :     {
     709             :         // notify our container listeners
     710           0 :         container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::Any(), uno::makeAny(xShape), uno::Any());
     711           0 :         m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent);
     712             :     }
     713           0 : }
     714             : // =============================================================================
     715             : } // namespace reportdesign
     716             : // =============================================================================
     717             : 
     718             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10