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

Generated by: LCOV version 1.10