Files
libreoffice/reportdesign/source/core/api/Section.cxx

662 lines
23 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2007-07-09 10:56:41 +00:00
#include "Section.hxx"
#include <comphelper/enumhelper.hxx>
#include <connectivity/dbtools.hxx>
#include <cppuhelper/supportsservice.hxx>
2007-07-09 10:56:41 +00:00
#include <com/sun/star/report/XReportComponent.hpp>
#include <com/sun/star/report/ForceNewPage.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include "corestrings.hrc"
#include "core_resource.hxx"
#include "core_resource.hrc"
#include <tools/debug.hxx>
#include "Tools.hxx"
#include "RptModel.hxx"
#include "RptPage.hxx"
#include "ReportDefinition.hxx"
#include "Shape.hxx"
#include <svx/unoshape.hxx>
#include <vcl/svapp.hxx>
2007-07-09 10:56:41 +00:00
#include "RptObject.hxx"
#include "ReportDrawPage.hxx"
#include <comphelper/property.hxx>
2007-07-09 10:56:41 +00:00
namespace reportdesign
{
2007-07-09 10:56:41 +00:00
using namespace com::sun::star;
using namespace comphelper;
uno::Sequence< OUString> lcl_getGroupAbsent()
2007-07-09 10:56:41 +00:00
{
OUString pProps[] = {
OUString(PROPERTY_CANGROW)
,OUString(PROPERTY_CANSHRINK)
2007-07-09 10:56:41 +00:00
};
return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
2007-07-09 10:56:41 +00:00
}
uno::Sequence< OUString> lcl_getAbsent(bool _bPageSection)
2007-07-09 10:56:41 +00:00
{
if ( _bPageSection )
{
OUString pProps[] = {
OUString(PROPERTY_FORCENEWPAGE)
,OUString(PROPERTY_NEWROWORCOL)
,OUString(PROPERTY_KEEPTOGETHER)
,OUString(PROPERTY_CANGROW)
,OUString(PROPERTY_CANSHRINK)
,OUString(PROPERTY_REPEATSECTION)
2007-07-09 10:56:41 +00:00
};
return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
2007-07-09 10:56:41 +00:00
}
OUString pProps[] = {
OUString(PROPERTY_CANGROW)
,OUString(PROPERTY_CANSHRINK)
,OUString(PROPERTY_REPEATSECTION)
2007-07-09 10:56:41 +00:00
};
return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
2007-07-09 10:56:41 +00:00
}
uno::Reference<report::XSection> OSection::createOSection(
const uno::Reference< report::XReportDefinition >& xParentDef,
const uno::Reference< uno::XComponentContext >& context,
bool const bPageSection)
{
OSection *const pNew =
new OSection(xParentDef, 0, context, lcl_getAbsent(bPageSection));
pNew->init();
return pNew;
}
uno::Reference<report::XSection> OSection::createOSection(
const uno::Reference< report::XGroup >& xParentGroup,
const uno::Reference< uno::XComponentContext >& context,
bool const)
{
OSection *const pNew =
new OSection(0, xParentGroup, context, lcl_getGroupAbsent());
pNew->init();
return pNew;
}
OSection::OSection(const uno::Reference< report::XReportDefinition >& xParentDef
,const uno::Reference< report::XGroup >& xParentGroup
2007-07-09 10:56:41 +00:00
,const uno::Reference< uno::XComponentContext >& context
,uno::Sequence< OUString> const& rStrings)
2007-07-09 10:56:41 +00:00
:SectionBase(m_aMutex)
,SectionPropertySet(context,SectionPropertySet::IMPLEMENTS_PROPERTY_SET,rStrings)
2007-07-09 10:56:41 +00:00
,m_aContainerListeners(m_aMutex)
,m_xContext(context)
,m_xGroup(xParentGroup)
,m_xReportDefinition(xParentDef)
2007-07-09 10:56:41 +00:00
,m_nHeight(3000)
,m_nBackgroundColor(COL_TRANSPARENT)
,m_nForceNewPage(report::ForceNewPage::NONE)
,m_nNewRowOrCol(report::ForceNewPage::NONE)
,m_bKeepTogether(false)
,m_bCanGrow(false)
,m_bCanShrink(false)
,m_bRepeatSection(false)
,m_bVisible(true)
,m_bBacktransparent(true)
2007-07-09 10:56:41 +00:00
,m_bInRemoveNotify(false)
,m_bInInsertNotify(false)
{
}
// TODO: VirtualFunctionFinder: This is virtual function!
2007-07-09 10:56:41 +00:00
OSection::~OSection()
{
}
2007-07-09 10:56:41 +00:00
//IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet)
IMPLEMENT_FORWARD_REFCOUNT( OSection, SectionBase )
uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
uno::Any aReturn = SectionBase::queryInterface(_rType);
if ( !aReturn.hasValue() )
aReturn = SectionPropertySet::queryInterface(_rType);
if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
return aReturn;
return aReturn;
2007-07-09 10:56:41 +00:00
}
void SAL_CALL OSection::dispose() throw(uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
OSL_ENSURE(!rBHelper.bDisposed,"Already disposed!");
2007-07-09 10:56:41 +00:00
SectionPropertySet::dispose();
uno::Reference<lang::XComponent> const xPageComponent(m_xDrawPage,
uno::UNO_QUERY);
if (xPageComponent.is())
{
xPageComponent->dispose();
}
2007-07-09 10:56:41 +00:00
cppu::WeakComponentImplHelperBase::dispose();
2007-07-09 10:56:41 +00:00
}
// TODO: VirtualFunctionFinder: This is virtual function!
2007-07-09 10:56:41 +00:00
void SAL_CALL OSection::disposing()
{
lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) );
m_aContainerListeners.disposeAndClear( aDisposeEvent );
m_xContext.clear();
}
OUString SAL_CALL OSection::getImplementationName( ) throw(uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
return OUString("com.sun.star.comp.report.Section");
2007-07-09 10:56:41 +00:00
}
uno::Sequence< OUString> OSection::getSupportedServiceNames_Static(void) throw( uno::RuntimeException )
2007-07-09 10:56:41 +00:00
{
uno::Sequence< OUString> aSupported(1);
2007-07-09 10:56:41 +00:00
aSupported.getArray()[0] = SERVICE_SECTION;
return aSupported;
}
uno::Sequence< OUString> SAL_CALL OSection::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
return getSupportedServiceNames_Static();
}
sal_Bool SAL_CALL OSection::supportsService( const OUString& _rServiceName ) throw(uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
return cppu::supportsService(this, _rServiceName);
2007-07-09 10:56:41 +00:00
}
2007-07-09 10:56:41 +00:00
void OSection::init()
{
SolarMutexGuard g; // lock while manipulating SdrModel
2007-07-09 10:56:41 +00:00
uno::Reference< report::XReportDefinition> xReport = getReportDefinition();
::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport);
assert(pModel && "No model set at the report definition!");
2007-07-09 10:56:41 +00:00
if ( pModel )
{
uno::Reference<report::XSection> const xSection(this);
SdrPage & rSdrPage(*pModel->createNewPage(xSection));
m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW);
m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW);
// apparently we may also get OReportDrawPage which doesn't support this
m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY);
m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW);
// fdo#53872: now also exchange the XDrawPage in the SdrPage so that
// rSdrPage.getUnoPage returns this
rSdrPage.SetUnoPage(this);
// createNewPage _should_ have stored away 2 uno::References to this,
// so our ref count cannot be 1 here, so this isn't destroyed here
assert(m_refCount > 1);
2007-07-09 10:56:41 +00:00
}
}
2007-07-09 10:56:41 +00:00
// XSection
sal_Bool SAL_CALL OSection::getVisible() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_bVisible;
}
void SAL_CALL OSection::setVisible( sal_Bool _visible ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
set(PROPERTY_VISIBLE,_visible,m_bVisible);
}
OUString SAL_CALL OSection::getName() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_sName;
}
void SAL_CALL OSection::setName( const OUString& _name ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
set(PROPERTY_NAME,_name,m_sName);
}
::sal_uInt32 SAL_CALL OSection::getHeight() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_nHeight;
}
void SAL_CALL OSection::setHeight( ::sal_uInt32 _height ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
set(PROPERTY_HEIGHT,_height,m_nHeight);
}
::sal_Int32 SAL_CALL OSection::getBackColor() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_bBacktransparent ? COL_TRANSPARENT : m_nBackgroundColor;
}
void SAL_CALL OSection::setBackColor( ::sal_Int32 _backgroundcolor ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
bool bTransparent = _backgroundcolor == static_cast<sal_Int32>(COL_TRANSPARENT);
setBackTransparent(bTransparent);
if ( !bTransparent )
set(PROPERTY_BACKCOLOR,_backgroundcolor,m_nBackgroundColor);
2007-07-09 10:56:41 +00:00
}
sal_Bool SAL_CALL OSection::getBackTransparent() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_bBacktransparent;
}
void SAL_CALL OSection::setBackTransparent( sal_Bool _backtransparent ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
set(PROPERTY_BACKTRANSPARENT,_backtransparent,m_bBacktransparent);
if ( _backtransparent )
set(PROPERTY_BACKCOLOR,static_cast<sal_Int32>(COL_TRANSPARENT),m_nBackgroundColor);
2007-07-09 10:56:41 +00:00
}
OUString SAL_CALL OSection::getConditionalPrintExpression() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_sConditionalPrintExpression;
}
void SAL_CALL OSection::setConditionalPrintExpression( const OUString& _conditionalprintexpression ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_sConditionalPrintExpression);
}
2007-07-09 10:56:41 +00:00
void OSection::checkNotPageHeaderFooter()
{
::osl::MutexGuard aGuard(m_aMutex);
uno::Reference< report::XReportDefinition > xRet = m_xReportDefinition;
if ( xRet.is() )
{
if ( xRet->getPageHeaderOn() && xRet->getPageHeader() == *this )
throw beans::UnknownPropertyException();
if ( xRet->getPageFooterOn() && xRet->getPageFooter() == *this )
throw beans::UnknownPropertyException();
}
}
::sal_Int16 SAL_CALL OSection::getForceNewPage() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
checkNotPageHeaderFooter();
return m_nForceNewPage;
}
void SAL_CALL OSection::setForceNewPage( ::sal_Int16 _forcenewpage ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
if ( _forcenewpage < report::ForceNewPage::NONE || _forcenewpage > report::ForceNewPage::BEFORE_AFTER_SECTION )
throwIllegallArgumentException("com::sun::star::report::ForceNewPage"
2007-07-09 10:56:41 +00:00
,*this
,1
,m_xContext);
checkNotPageHeaderFooter();
set(PROPERTY_FORCENEWPAGE,_forcenewpage,m_nForceNewPage);
}
::sal_Int16 SAL_CALL OSection::getNewRowOrCol() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
checkNotPageHeaderFooter();
return m_nNewRowOrCol;
}
void SAL_CALL OSection::setNewRowOrCol( ::sal_Int16 _newroworcol ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
if ( _newroworcol < report::ForceNewPage::NONE || _newroworcol > report::ForceNewPage::BEFORE_AFTER_SECTION )
throwIllegallArgumentException("com::sun::star::report::ForceNewPage"
2007-07-09 10:56:41 +00:00
,*this
,1
,m_xContext);
checkNotPageHeaderFooter();
set(PROPERTY_NEWROWORCOL,_newroworcol,m_nNewRowOrCol);
}
sal_Bool SAL_CALL OSection::getKeepTogether() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
checkNotPageHeaderFooter();
return m_bKeepTogether;
}
void SAL_CALL OSection::setKeepTogether( sal_Bool _keeptogether ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
{
::osl::MutexGuard aGuard(m_aMutex);
checkNotPageHeaderFooter();
}
2007-07-09 10:56:41 +00:00
set(PROPERTY_KEEPTOGETHER,_keeptogether,m_bKeepTogether);
}
sal_Bool SAL_CALL OSection::getCanGrow() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
}
void SAL_CALL OSection::setCanGrow( sal_Bool /*_cangrow*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
}
sal_Bool SAL_CALL OSection::getCanShrink() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
}
void SAL_CALL OSection::setCanShrink( sal_Bool /*_canshrink*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
}
sal_Bool SAL_CALL OSection::getRepeatSection() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
uno::Reference< report::XGroup > xGroup = m_xGroup;
if ( !xGroup.is() )
throw beans::UnknownPropertyException();
return m_bRepeatSection;
}
void SAL_CALL OSection::setRepeatSection( sal_Bool _repeatsection ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
{
::osl::MutexGuard aGuard(m_aMutex);
uno::Reference< report::XGroup > xGroup = m_xGroup;
if ( !xGroup.is() )
throw beans::UnknownPropertyException();
}
set(PROPERTY_REPEATSECTION,_repeatsection,m_bRepeatSection);
}
uno::Reference< report::XGroup > SAL_CALL OSection::getGroup() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_xGroup;
}
uno::Reference< report::XReportDefinition > SAL_CALL OSection::getReportDefinition() throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
uno::Reference< report::XReportDefinition > xRet = m_xReportDefinition;
uno::Reference< report::XGroup > xGroup = m_xGroup;
if ( !xRet.is() && xGroup.is() )
{
uno::Reference< report::XGroups> xGroups(xGroup->getGroups());
2007-07-09 10:56:41 +00:00
if ( xGroups.is() )
xRet = xGroups->getReportDefinition();
}
return xRet;
}
2007-07-09 10:56:41 +00:00
// XChild
uno::Reference< uno::XInterface > SAL_CALL OSection::getParent( ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
uno::Reference< uno::XInterface > xRet;
{
::osl::MutexGuard aGuard(m_aMutex);
xRet = m_xReportDefinition;
if ( !xRet.is() )
xRet = m_xGroup;
}
return xRet;
}
void SAL_CALL OSection::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
throw lang::NoSupportException();
}
2007-07-09 10:56:41 +00:00
// XContainer
void SAL_CALL OSection::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
m_aContainerListeners.addInterface(xListener);
}
void SAL_CALL OSection::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
m_aContainerListeners.removeInterface(xListener);
}
2007-07-09 10:56:41 +00:00
// XElementAccess
uno::Type SAL_CALL OSection::getElementType( ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
return cppu::UnoType<report::XReportComponent>::get();
2007-07-09 10:56:41 +00:00
}
sal_Bool SAL_CALL OSection::hasElements( ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_xDrawPage.is() ? m_xDrawPage->hasElements() : sal_False;
}
2007-07-09 10:56:41 +00:00
// XIndexAccess
::sal_Int32 SAL_CALL OSection::getCount( ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_xDrawPage.is() ? m_xDrawPage->getCount() : 0;
}
uno::Any SAL_CALL OSection::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return m_xDrawPage.is() ? m_xDrawPage->getByIndex(Index) : uno::Any();
2007-07-09 10:56:41 +00:00
}
2007-07-09 10:56:41 +00:00
// XEnumerationAccess
uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration( ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
::osl::MutexGuard aGuard(m_aMutex);
return new ::comphelper::OEnumerationByIndex(static_cast<XSection*>(this));
2007-07-09 10:56:41 +00:00
}
uno::Reference< beans::XPropertySetInfo > SAL_CALL OSection::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
return SectionPropertySet::getPropertySetInfo();
}
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)
2007-07-09 10:56:41 +00:00
{
SectionPropertySet::setPropertyValue( aPropertyName, aValue );
}
uno::Any SAL_CALL OSection::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
return SectionPropertySet::getPropertyValue( PropertyName);
}
void SAL_CALL OSection::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
SectionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
}
void SAL_CALL OSection::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
SectionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
}
void SAL_CALL OSection::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
SectionPropertySet::addVetoableChangeListener( PropertyName, aListener );
}
void SAL_CALL OSection::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
SectionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
}
2007-07-09 10:56:41 +00:00
void OSection::lcl_copySection(const uno::Reference< report::XSection>& _xSource,uno::Reference< report::XSection>& _xDest)
{
if ( _xSource.is() )
{
::comphelper::copyProperties(_xSource.get(),_xDest.get());
sal_Int32 nCount = _xSource->getCount();
for(sal_Int32 i = 0;i != nCount;++i)
{
uno::Reference<util::XCloneable> xClone(_xSource->getByIndex(i),uno::UNO_QUERY);
OSL_ENSURE(xClone.is(),"No XCloneable interface found!");
if ( xClone.is() )
{
uno::Reference< drawing::XShape> xShape(xClone->createClone(),uno::UNO_QUERY);
_xDest->add(xShape);
}
}
}
}
void SAL_CALL OSection::add( const uno::Reference< drawing::XShape >& xShape ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
{
::osl::MutexGuard aGuard(m_aMutex);
m_bInInsertNotify = true;
OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!");
m_xDrawPage->add(xShape);
m_bInInsertNotify = false;
}
notifyElementAdded(xShape);
}
void SAL_CALL OSection::remove( const uno::Reference< drawing::XShape >& xShape ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
{
::osl::MutexGuard aGuard(m_aMutex);
m_bInRemoveNotify = true;
OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!");
m_xDrawPage->remove(xShape);
m_bInRemoveNotify = false;
}
notifyElementRemoved(xShape);
}
// XShapeGrouper
uno::Reference< drawing::XShapeGroup > SAL_CALL
OSection::group(uno::Reference< drawing::XShapes > const& xShapes)
throw (uno::RuntimeException, std::exception)
{
// no lock because m_xDrawPage_ShapeGrouper is const
return (m_xDrawPage_ShapeGrouper.is())
? m_xDrawPage_ShapeGrouper->group(xShapes)
: 0;
}
void SAL_CALL
OSection::ungroup(uno::Reference<drawing::XShapeGroup> const& xGroup)
throw (uno::RuntimeException, std::exception)
{
// no lock because m_xDrawPage_ShapeGrouper is const
if (m_xDrawPage_ShapeGrouper.is()) {
m_xDrawPage_ShapeGrouper->ungroup(xGroup);
}
}
// XFormsSupplier
uno::Reference<container::XNameContainer> SAL_CALL OSection::getForms()
throw (uno::RuntimeException, std::exception)
{
// no lock because m_xDrawPage_FormSupplier is const
return (m_xDrawPage_FormSupplier.is())
? m_xDrawPage_FormSupplier->getForms()
: 0;
}
// XFormsSupplier2
sal_Bool SAL_CALL OSection::hasForms() throw (uno::RuntimeException, std::exception)
{
// no lock because m_xDrawPage_FormSupplier is const
return (m_xDrawPage_FormSupplier.is())
? m_xDrawPage_FormSupplier->hasForms()
: 0;
}
2007-07-09 10:56:41 +00:00
// com::sun::star::lang::XUnoTunnel
sal_Int64 OSection::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw (uno::RuntimeException, std::exception)
2007-07-09 10:56:41 +00:00
{
if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
2007-07-09 10:56:41 +00:00
return reinterpret_cast<sal_Int64>(this);
return (m_xDrawPage_Tunnel.is()) ? m_xDrawPage_Tunnel->getSomething(rId) : 0;
2007-07-09 10:56:41 +00:00
}
2007-07-09 10:56:41 +00:00
OSection* OSection::getImplementation( const uno::Reference< uno::XInterface >& _rxComponent )
{
OSection* pContent( NULL );
uno::Reference< lang::XUnoTunnel > xUnoTunnel( _rxComponent, uno::UNO_QUERY );
if ( xUnoTunnel.is() )
pContent = reinterpret_cast< OSection* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
return pContent;
}
2007-07-09 10:56:41 +00:00
uno::Sequence< sal_Int8 > OSection::getUnoTunnelImplementationId()
{
static ::cppu::OImplementationId * pId = 0;
if (! pId)
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
if (! pId)
{
static ::cppu::OImplementationId aId;
pId = &aId;
}
}
return pId->getImplementationId();
}
2007-07-09 10:56:41 +00:00
void OSection::notifyElementAdded(const uno::Reference< drawing::XShape >& xShape )
{
if ( !m_bInInsertNotify )
{
container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::Any(), uno::makeAny(xShape), uno::Any());
m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent);
}
}
2007-07-09 10:56:41 +00:00
void OSection::notifyElementRemoved(const uno::Reference< drawing::XShape >& xShape)
{
if ( !m_bInRemoveNotify )
{
// notify our container listeners
container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::Any(), uno::makeAny(xShape), uno::Any());
m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent);
}
}
2007-07-09 10:56:41 +00:00
} // namespace reportdesign
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */