diff options
Diffstat (limited to 'reportdesign/source/core')
61 files changed, 17060 insertions, 0 deletions
diff --git a/reportdesign/source/core/api/FixedLine.cxx b/reportdesign/source/core/api/FixedLine.cxx new file mode 100644 index 000000000000..6c24ed17955a --- /dev/null +++ b/reportdesign/source/core/api/FixedLine.cxx @@ -0,0 +1,585 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "FixedLine.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include "core_resource.hxx" +#include <comphelper/sequence.hxx> +#include <tools/debug.hxx> +#include <comphelper/property.hxx> +#include "Tools.hxx" +#include "FormatCondition.hxx" +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include <boost/bind.hpp> +#include "ReportHelperImpl.hxx" + +#define MIN_WIDTH 80 +#define MIN_HEIGHT 20 +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +uno::Sequence< ::rtl::OUString > lcl_getLineOptionals() +{ + ::rtl::OUString pProps[] = { + PROPERTY_DATAFIELD + ,PROPERTY_DEFAULTCONTROL + ,PROPERTY_CONTROLBORDER + ,PROPERTY_CONTROLBORDERCOLOR + ,PROPERTY_CHARCOLOR + ,PROPERTY_CHAREMPHASIS + ,PROPERTY_CHARFONTCHARSET + ,PROPERTY_CHARFONTFAMILY + ,PROPERTY_CHARFONTNAME + ,PROPERTY_CHARFONTPITCH + ,PROPERTY_CHARFONTSTYLENAME + ,PROPERTY_CHARHEIGHT + ,PROPERTY_CHARPOSTURE + ,PROPERTY_CHARRELIEF + ,PROPERTY_FONTDESCRIPTOR + ,PROPERTY_FONTDESCRIPTORASIAN + ,PROPERTY_FONTDESCRIPTORCOMPLEX + ,PROPERTY_CONTROLTEXTEMPHASISMARK + ,PROPERTY_CHARROTATION + ,PROPERTY_CHARSCALEWIDTH + ,PROPERTY_CHARSTRIKEOUT + ,PROPERTY_CHARUNDERLINECOLOR + ,PROPERTY_CHARUNDERLINE + ,PROPERTY_CHARWEIGHT + ,PROPERTY_CHARWORDMODE + ,PROPERTY_CONTROLBACKGROUND + ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT + ,PROPERTY_CHARFLASH + ,PROPERTY_CHARAUTOKERNING + ,PROPERTY_CHARESCAPEMENTHEIGHT + ,PROPERTY_CHARLOCALE + ,PROPERTY_CHARESCAPEMENT + ,PROPERTY_CHARCASEMAP + ,PROPERTY_CHARCOMBINEISON + ,PROPERTY_CHARCOMBINEPREFIX + ,PROPERTY_CHARCOMBINESUFFIX + ,PROPERTY_CHARHIDDEN + ,PROPERTY_CHARSHADOWED + ,PROPERTY_CHARCONTOURED + ,PROPERTY_HYPERLINKURL + ,PROPERTY_HYPERLINKTARGET + ,PROPERTY_HYPERLINKNAME + ,PROPERTY_VISITEDCHARSTYLENAME + ,PROPERTY_UNVISITEDCHARSTYLENAME + ,PROPERTY_CHARKERNING + ,PROPERTY_PRINTREPEATEDVALUES + ,PROPERTY_CONDITIONALPRINTEXPRESSION + ,PROPERTY_PRINTWHENGROUPCHANGE + ,PROPERTY_MASTERFIELDS + ,PROPERTY_DETAILFIELDS + ,PROPERTY_PARAADJUST + + , PROPERTY_CHAREMPHASISASIAN + , PROPERTY_CHARFONTNAMEASIAN + , PROPERTY_CHARFONTSTYLENAMEASIAN + , PROPERTY_CHARFONTFAMILYASIAN + , PROPERTY_CHARFONTCHARSETASIAN + , PROPERTY_CHARFONTPITCHASIAN + , PROPERTY_CHARHEIGHTASIAN + , PROPERTY_CHARUNDERLINEASIAN + , PROPERTY_CHARWEIGHTASIAN + , PROPERTY_CHARPOSTUREASIAN + , PROPERTY_CHARWORDMODEASIAN + , PROPERTY_CHARROTATIONASIAN + , PROPERTY_CHARSCALEWIDTHASIAN + , PROPERTY_CHARLOCALEASIAN + , PROPERTY_CHAREMPHASISCOMPLEX + , PROPERTY_CHARFONTNAMECOMPLEX + , PROPERTY_CHARFONTSTYLENAMECOMPLEX + , PROPERTY_CHARFONTFAMILYCOMPLEX + , PROPERTY_CHARFONTCHARSETCOMPLEX + , PROPERTY_CHARFONTPITCHCOMPLEX + , PROPERTY_CHARHEIGHTCOMPLEX + , PROPERTY_CHARUNDERLINECOMPLEX + , PROPERTY_CHARWEIGHTCOMPLEX + , PROPERTY_CHARPOSTURECOMPLEX + , PROPERTY_CHARWORDMODECOMPLEX + , PROPERTY_CHARROTATIONCOMPLEX + , PROPERTY_CHARSCALEWIDTHCOMPLEX + , PROPERTY_CHARLOCALECOMPLEX + + + }; + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} +DBG_NAME(rpt_OFixedLine) +// ----------------------------------------------------------------------------- +OFixedLine::OFixedLine(uno::Reference< uno::XComponentContext > const & _xContext) +:FixedLineBase(m_aMutex) +,FixedLinePropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getLineOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nOrientation(1) +,m_LineColor(0) +,m_LineTransparence(0) +,m_LineWidth(0) +{ + DBG_CTOR(rpt_OFixedLine,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDLINE,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_nWidth = MIN_WIDTH; +} +// ----------------------------------------------------------------------------- +OFixedLine::OFixedLine(uno::Reference< uno::XComponentContext > const & _xContext + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,uno::Reference< drawing::XShape >& _xShape + ,sal_Int32 _nOrientation) +:FixedLineBase(m_aMutex) +,FixedLinePropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getLineOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nOrientation(_nOrientation) +,m_LineColor(0) +,m_LineTransparence(0) +,m_LineWidth(0) +{ + DBG_CTOR(rpt_OFixedLine,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDLINE,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_xFactory = _xFactory; + osl_incrementInterlockedCount( &m_refCount ); + try + { + awt::Size aSize = _xShape->getSize(); + if ( m_nOrientation == 1 ) + { + if ( aSize.Width < MIN_WIDTH ) + { + aSize.Width = MIN_WIDTH; + _xShape->setSize(aSize); + } + } + else if ( MIN_HEIGHT > aSize.Height ) + { + aSize.Height = MIN_HEIGHT; + _xShape->setSize(aSize); + } + m_aProps.aComponent.setShape(_xShape,this,m_refCount); + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"OFixedLine::OFixedLine: Exception caught!"); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OFixedLine::~OFixedLine() +{ + DBG_DTOR(rpt_OFixedLine,NULL); +} +// ----------------------------------------------------------------------------- +//IMPLEMENT_FORWARD_XINTERFACE2(OFixedLine,FixedLineBase,FixedLinePropertySet) +IMPLEMENT_FORWARD_REFCOUNT( OFixedLine, FixedLineBase ) +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OFixedLine::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = FixedLineBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = FixedLinePropertySet::queryInterface(_rType); + if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) + return aReturn; + + return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::dispose() throw(uno::RuntimeException) +{ + FixedLinePropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OFixedLine::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFixedLine")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFixedLine::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OFixedLine::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_FIXEDLINE; + + return aServices; +} +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OFixedLine::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OFixedLine(xContext)); +} + +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OFixedLine::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OFixedLine::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +// XReportComponent +REPORTCOMPONENT_IMPL3(OFixedLine,m_aProps.aComponent) +REPORTCOMPONENT_NOMASTERDETAIL(OFixedLine) +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OFixedLine::getControlBorder( ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setControlBorder( ::sal_Int16 /*_border*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OFixedLine::getControlBorderColor() throw (beans::UnknownPropertyException,uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setControlBorderColor( ::sal_Int32 /*_bordercolor*/ ) throw (beans::UnknownPropertyException,lang::IllegalArgumentException,uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedLine::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return FixedLinePropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedLinePropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFixedLine::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return FixedLinePropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedLinePropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedLinePropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedLinePropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedLinePropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XReportControlModel +::rtl::OUString SAL_CALL OFixedLine::getDataField() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setDataField( const ::rtl::OUString& /*_datafield*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OFixedLine::getControlBackground() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setControlBackground( ::sal_Int32 /*_backgroundcolor*/ ) throw (uno::RuntimeException,beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFixedLine::getControlBackgroundTransparent() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setControlBackgroundTransparent( ::sal_Bool /*_controlbackgroundtransparent*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFixedLine::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setPrintWhenGroupChange( ::sal_Bool /*_printwhengroupchange*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFixedLine::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setConditionalPrintExpression( const ::rtl::OUString& /*_conditionalprintexpression*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +// XCloneable +uno::Reference< util::XCloneable > SAL_CALL OFixedLine::createClone( ) throw (uno::RuntimeException) +{ + uno::Reference< report::XReportComponent> xSource = this; + uno::Reference< report::XFixedLine> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDLINE),uno::UNO_QUERY_THROW); + return xSet.get(); +} +// ----------------------------------------------------------------------------- + +// XFixedLine +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OFixedLine::getOrientation() throw (beans::UnknownPropertyException,uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_nOrientation; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setOrientation( ::sal_Int32 _orientation ) throw (beans::UnknownPropertyException,uno::RuntimeException) +{ + set(PROPERTY_ORIENTATION,_orientation,m_nOrientation); +} +// ----------------------------------------------------------------------------- +drawing::LineStyle SAL_CALL OFixedLine::getLineStyle() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_LineStyle; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setLineStyle( drawing::LineStyle _linestyle ) throw (uno::RuntimeException) +{ + set(PROPERTY_LINESTYLE,_linestyle,m_LineStyle); +} +// ----------------------------------------------------------------------------- +drawing::LineDash SAL_CALL OFixedLine::getLineDash() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_LineDash; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setLineDash( const drawing::LineDash& _linedash ) throw (uno::RuntimeException) +{ + set(PROPERTY_LINEDASH,_linedash,m_LineDash); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OFixedLine::getLineColor() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_LineColor; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setLineColor( ::sal_Int32 _linecolor ) throw (uno::RuntimeException) +{ + set(PROPERTY_LINECOLOR,_linecolor,m_LineColor); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OFixedLine::getLineTransparence() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_LineTransparence; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setLineTransparence( ::sal_Int16 _linetransparence ) throw (uno::RuntimeException) +{ + set(PROPERTY_LINETRANSPARENCE,_linetransparence,m_LineTransparence); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OFixedLine::getLineWidth() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_LineWidth; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setLineWidth( ::sal_Int32 _linewidth ) throw (uno::RuntimeException) +{ + set(PROPERTY_LINEWIDTH,_linewidth,m_LineWidth); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OFixedLine::getParent( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getParent(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + OShapeHelper::setParent(Parent,this); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XFormatCondition > SAL_CALL OFixedLine::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException) +{ + return new OFormatCondition(m_aProps.aComponent.m_xContext); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OFixedLine::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.addContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.removeContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OFixedLine::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFixedLine::hasElements( ) throw (uno::RuntimeException) +{ + return m_aProps.hasElements(); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OFixedLine::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.insertByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.removeByIndex(Index); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OFixedLine::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.replaceByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OFixedLine::getCount( ) throw (uno::RuntimeException) +{ + return m_aProps.getCount(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFixedLine::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_aProps.getByIndex( Index ); +} +// ----------------------------------------------------------------------------- +// XShape +awt::Point SAL_CALL OFixedLine::getPosition( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getPosition(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) +{ + OShapeHelper::setPosition(aPosition,this); +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OFixedLine::getSize( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getSize(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedLine::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + if ( (aSize.Width < MIN_WIDTH && m_nOrientation == 1) || (aSize.Height < MIN_HEIGHT && m_nOrientation == 0) ) + throw beans::PropertyVetoException(); + OShapeHelper::setSize(aSize,this); +} +// ----------------------------------------------------------------------------- +// XShapeDescriptor +::rtl::OUString SAL_CALL OFixedLine::getShapeType( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_aProps.aComponent.m_xShape.is() ) + return m_aProps.aComponent.m_xShape->getShapeType(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFixedLine::getHyperLinkURL() throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +void SAL_CALL OFixedLine::setHyperLinkURL(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +::rtl::OUString SAL_CALL OFixedLine::getHyperLinkTarget() throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +void SAL_CALL OFixedLine::setHyperLinkTarget(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +::rtl::OUString SAL_CALL OFixedLine::getHyperLinkName() throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +void SAL_CALL OFixedLine::setHyperLinkName(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} + +NO_REPORTCONTROLFORMAT_IMPL(OFixedLine) + +::sal_Bool SAL_CALL OFixedLine::getPrintRepeatedValues() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +void SAL_CALL OFixedLine::setPrintRepeatedValues( ::sal_Bool /*_printrepeatedvalues*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} + +// ----------------------------------------------------------------------------- +// ============================================================================= +} // namespace reportdesign +// ============================================================================= + diff --git a/reportdesign/source/core/api/FixedText.cxx b/reportdesign/source/core/api/FixedText.cxx new file mode 100644 index 000000000000..7e535f0ee40f --- /dev/null +++ b/reportdesign/source/core/api/FixedText.cxx @@ -0,0 +1,347 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "FixedText.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#include <com/sun/star/beans/XPropertyState.hpp> +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include "core_resource.hxx" +#include <comphelper/sequence.hxx> +#include "Tools.hxx" +#include <tools/debug.hxx> +#include <comphelper/property.hxx> +#include "FormatCondition.hxx" +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include "ReportHelperImpl.hxx" +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +uno::Sequence< ::rtl::OUString > lcl_getFixedTextOptionals() +{ + ::rtl::OUString pProps[] = { PROPERTY_DATAFIELD,PROPERTY_MASTERFIELDS,PROPERTY_DETAILFIELDS }; + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} +DBG_NAME( rpt_OFixedText ) +// ----------------------------------------------------------------------------- +OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext) +:FixedTextBase(m_aMutex) +,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +{ + DBG_CTOR( rpt_OFixedText,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_nBorder = 0; // no border +} +// ----------------------------------------------------------------------------- +OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,uno::Reference< drawing::XShape >& _xShape) +:FixedTextBase(m_aMutex) +,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +{ + DBG_CTOR( rpt_OFixedText,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_nBorder = 0; // no border + m_aProps.aComponent.m_xFactory = _xFactory; + osl_incrementInterlockedCount( &m_refCount ); + { + m_aProps.aComponent.setShape(_xShape,this,m_refCount); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OFixedText::~OFixedText() +{ + DBG_DTOR( rpt_OFixedText,NULL); +} +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase ) +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = FixedTextBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = FixedTextPropertySet::queryInterface(_rType); + if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) + return aReturn; + + return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn); +} + +//IMPLEMENT_FORWARD_XINTERFACE2(OFixedText,FixedTextBase,FixedTextPropertySet) +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::dispose() throw(uno::RuntimeException) +{ + FixedTextPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); + uno::Reference< report::XFixedText> xHoldAlive = this; +} +// ----------------------------------------------------------------------------- +::rtl::OUString OFixedText::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFixedText")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFixedText::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OFixedText::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1);//2); + aServices.getArray()[0] = SERVICE_FIXEDTEXT; + //aServices.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")); + + return aServices; +} +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OFixedText(xContext)); +} + +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OFixedText::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OFixedText::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +// XReportComponent +REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent) +REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent) +REPORTCOMPONENT_NOMASTERDETAIL(OFixedText) +REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties) +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return FixedTextPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedTextPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFixedText::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return FixedTextPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XReportControlModel +::rtl::OUString SAL_CALL OFixedText::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setDataField( const ::rtl::OUString& /*_datafield*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- + +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.bPrintWhenGroupChange; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFixedText::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aConditionalPrintExpression; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression); +} +// ----------------------------------------------------------------------------- + +// XCloneable +uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( ) throw (uno::RuntimeException) +{ + uno::Reference< report::XReportComponent> xSource = this; + uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW); + return xSet.get(); +} +// ----------------------------------------------------------------------------- + +// XFixedText +::rtl::OUString SAL_CALL OFixedText::getLabel() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_sLabel; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setLabel( const ::rtl::OUString& _label ) throw (uno::RuntimeException) +{ + set(PROPERTY_LABEL,_label,m_sLabel); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getParent(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + OShapeHelper::setParent(Parent,this); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException) +{ + return new OFormatCondition(m_aProps.aComponent.m_xContext); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.addContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.removeContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OFixedText::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFixedText::hasElements( ) throw (uno::RuntimeException) +{ + return m_aProps.hasElements(); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.insertByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.removeByIndex(Index); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.replaceByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OFixedText::getCount( ) throw (uno::RuntimeException) +{ + return m_aProps.getCount(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_aProps.getByIndex( Index ); +} +// ----------------------------------------------------------------------------- +// XShape +awt::Point SAL_CALL OFixedText::getPosition( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getPosition(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) +{ + OShapeHelper::setPosition(aPosition,this); +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OFixedText::getSize( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getSize(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFixedText::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + OShapeHelper::setSize(aSize,this); +} +// ----------------------------------------------------------------------------- + +// XShapeDescriptor +::rtl::OUString SAL_CALL OFixedText::getShapeType( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_aProps.aComponent.m_xShape.is() ) + return m_aProps.aComponent.m_xShape->getShapeType(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// ============================================================================= +} // namespace reportdesign +// ============================================================================= + diff --git a/reportdesign/source/core/api/FormatCondition.cxx b/reportdesign/source/core/api/FormatCondition.cxx new file mode 100644 index 000000000000..95e6e4e87574 --- /dev/null +++ b/reportdesign/source/core/api/FormatCondition.cxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "FormatCondition.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#include <tools/debug.hxx> +#include <connectivity/dbtools.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/property.hxx> +#include "Tools.hxx" +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include "ReportHelperImpl.hxx" +#include "corestrings.hrc" +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OFormatCondition::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OFormatCondition(xContext)); +} + +DBG_NAME( rpt_OFormatCondition ) +// ----------------------------------------------------------------------------- +OFormatCondition::OFormatCondition(uno::Reference< uno::XComponentContext > const & _xContext) +:FormatConditionBase(m_aMutex) +,FormatConditionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,m_bEnabled(sal_True) +{ + DBG_CTOR( rpt_OFormatCondition,NULL); +} +// ----------------------------------------------------------------------------- +OFormatCondition::~OFormatCondition() +{ + DBG_DTOR( rpt_OFormatCondition,NULL); +} +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2(OFormatCondition,FormatConditionBase,FormatConditionPropertySet) +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::dispose() throw(uno::RuntimeException) +{ + FormatConditionPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OFormatCondition::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFormatCondition")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFormatCondition::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OFormatCondition::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_FORMATCONDITION; + + return aServices; +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OFormatCondition::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OFormatCondition::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OFormatCondition::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return FormatConditionPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormatConditionPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFormatCondition::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return FormatConditionPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormatConditionPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormatConditionPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormatConditionPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormatConditionPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XFormatCondition +::sal_Bool SAL_CALL OFormatCondition::getEnabled() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_bEnabled; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::setEnabled( ::sal_Bool _enabled ) throw (uno::RuntimeException) +{ + set(PROPERTY_ENABLED,_enabled,m_bEnabled); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFormatCondition::getFormula() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_sFormula; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormatCondition::setFormula( const ::rtl::OUString& _formula ) throw (uno::RuntimeException) +{ + set(PROPERTY_FORMULA,_formula,m_sFormula); +} +// ----------------------------------------------------------------------------- +// XReportControlFormat +REPORTCONTROLFORMAT_IMPL(OFormatCondition,m_aFormatProperties) +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/FormattedField.cxx b/reportdesign/source/core/api/FormattedField.cxx new file mode 100644 index 000000000000..ee94e7a97d10 --- /dev/null +++ b/reportdesign/source/core/api/FormattedField.cxx @@ -0,0 +1,387 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "FormattedField.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include "core_resource.hxx" +#include <comphelper/sequence.hxx> +#include <tools/debug.hxx> +#include <connectivity/dbtools.hxx> +#include <comphelper/property.hxx> +#include "Tools.hxx" +#include "FormatCondition.hxx" +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include "ReportHelperImpl.hxx" +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OFormattedField::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OFormattedField(xContext)); +} + +uno::Sequence< ::rtl::OUString > lcl_getFormattedFieldOptionals() +{ + ::rtl::OUString pProps[] = { PROPERTY_MASTERFIELDS,PROPERTY_DETAILFIELDS }; + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} +DBG_NAME( rpt_OFormattedField ) +// ----------------------------------------------------------------------------- +OFormattedField::OFormattedField(uno::Reference< uno::XComponentContext > const & _xContext) +:FormattedFieldBase(m_aMutex) +,FormattedFieldPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFormattedFieldOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nFormatKey(0) +{ + DBG_CTOR( rpt_OFormattedField,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FORMATTEDFIELD,m_aProps.aComponent.m_xContext->getServiceManager()); +} +// ----------------------------------------------------------------------------- +OFormattedField::OFormattedField(uno::Reference< uno::XComponentContext > const & _xContext + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,uno::Reference< drawing::XShape >& _xShape) +:FormattedFieldBase(m_aMutex) +,FormattedFieldPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFormattedFieldOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nFormatKey(0) +{ + DBG_CTOR( rpt_OFormattedField,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FORMATTEDFIELD,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_xFactory = _xFactory; + osl_incrementInterlockedCount( &m_refCount ); + { + m_aProps.aComponent.setShape(_xShape,this,m_refCount); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OFormattedField::~OFormattedField() +{ + DBG_DTOR( rpt_OFormattedField,NULL); +} +// ----------------------------------------------------------------------------- +//IMPLEMENT_FORWARD_XINTERFACE2(OFormattedField,FormattedFieldBase,FormattedFieldPropertySet) +IMPLEMENT_FORWARD_REFCOUNT( OFormattedField, FormattedFieldBase ) +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OFormattedField::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = FormattedFieldBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = FormattedFieldPropertySet::queryInterface(_rType); + if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) + return aReturn; + + return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::dispose() throw(uno::RuntimeException) +{ + FormattedFieldPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); + m_xFormatsSupplier.clear(); + m_xFunction.clear(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OFormattedField::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFormattedField")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFormattedField::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OFormattedField::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(2); + aServices.getArray()[0] = SERVICE_FORMATTEDFIELD; + aServices.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel")); + + return aServices; +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OFormattedField::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OFormattedField::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +// XReportComponent +REPORTCOMPONENT_IMPL(OFormattedField,m_aProps.aComponent) +REPORTCOMPONENT_IMPL2(OFormattedField,m_aProps.aComponent) +REPORTCOMPONENT_NOMASTERDETAIL(OFormattedField) +REPORTCONTROLFORMAT_IMPL(OFormattedField,m_aProps.aFormatProperties) + +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OFormattedField::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return FormattedFieldPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + // special case here /// TODO check + if ( !aValue.hasValue() && aPropertyName == PROPERTY_FORMATKEY ) + m_nFormatKey = 0; + else + FormattedFieldPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFormattedField::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return FormattedFieldPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormattedFieldPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormattedFieldPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormattedFieldPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FormattedFieldPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XReportControlModel +::rtl::OUString SAL_CALL OFormattedField::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aDataField; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setDataField( const ::rtl::OUString& _datafield ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_DATAFIELD,_datafield,m_aProps.aDataField); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFormattedField::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.bPrintWhenGroupChange; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFormattedField::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aConditionalPrintExpression; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression); +} + +// ----------------------------------------------------------------------------- + +// XCloneable +uno::Reference< util::XCloneable > SAL_CALL OFormattedField::createClone( ) throw (uno::RuntimeException) +{ + uno::Reference< report::XReportComponent> xSource = this; + uno::Reference< report::XFormattedField> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FORMATTEDFIELD),uno::UNO_QUERY_THROW); + + if ( xSet.is() ) + { + ::std::vector< uno::Reference< report::XFormatCondition> >::iterator aIter = m_aProps.m_aFormatConditions.begin(); + ::std::vector< uno::Reference< report::XFormatCondition> >::iterator aEnd = m_aProps.m_aFormatConditions.end(); + for (sal_Int32 i = 0; aIter != aEnd; ++aIter,++i) + { + uno::Reference< report::XFormatCondition > xCond = xSet->createFormatCondition(); + ::comphelper::copyProperties(aIter->get(),xCond.get()); + xSet->insertByIndex(i,uno::makeAny(xCond)); + } + } + return xSet.get(); +} +// ----------------------------------------------------------------------------- +// XFormattedField +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OFormattedField::getFormatKey() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_nFormatKey; +} + +void SAL_CALL OFormattedField::setFormatKey(::sal_Int32 _formatkey) throw (uno::RuntimeException) +{ + set(PROPERTY_FORMATKEY,_formatkey,m_nFormatKey); +} +// ----------------------------------------------------------------------------- +uno::Reference< util::XNumberFormatsSupplier > SAL_CALL OFormattedField::getFormatsSupplier() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_xFormatsSupplier.is() ) + { + uno::Reference< report::XSection> xSection = getSection(); + if ( xSection.is() ) + m_xFormatsSupplier.set(xSection->getReportDefinition(),uno::UNO_QUERY); + if ( !m_xFormatsSupplier.is() ) + { + uno::Reference< beans::XPropertySet> xProp(::dbtools::findDataSource(getParent()),uno::UNO_QUERY); + if ( xProp.is() ) + m_xFormatsSupplier.set(xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormatsSupplier"))),uno::UNO_QUERY); + } + } + return m_xFormatsSupplier; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& _formatssupplier ) throw (uno::RuntimeException) +{ + set(PROPERTY_FORMATSSUPPLIER,_formatssupplier,m_xFormatsSupplier); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OFormattedField::getParent( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getParent(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + OShapeHelper::setParent(Parent,this); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XFormatCondition > SAL_CALL OFormattedField::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException) +{ + return new OFormatCondition(m_aProps.aComponent.m_xContext); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OFormattedField::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.addContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.removeContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OFormattedField::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFormattedField::hasElements( ) throw (uno::RuntimeException) +{ + return m_aProps.hasElements(); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OFormattedField::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.insertByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.removeByIndex(Index); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OFormattedField::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.replaceByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OFormattedField::getCount( ) throw (uno::RuntimeException) +{ + return m_aProps.getCount(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFormattedField::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_aProps.getByIndex( Index ); +} +// ----------------------------------------------------------------------------- +// XShape +awt::Point SAL_CALL OFormattedField::getPosition( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getPosition(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) +{ + OShapeHelper::setPosition(aPosition,this); +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OFormattedField::getSize( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getSize(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFormattedField::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + OShapeHelper::setSize(aSize,this); +} +// ----------------------------------------------------------------------------- + +// XShapeDescriptor +::rtl::OUString SAL_CALL OFormattedField::getShapeType( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_aProps.aComponent.m_xShape.is() ) + return m_aProps.aComponent.m_xShape->getShapeType(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/Function.cxx b/reportdesign/source/core/api/Function.cxx new file mode 100644 index 000000000000..506d70e8adcc --- /dev/null +++ b/reportdesign/source/core/api/Function.cxx @@ -0,0 +1,222 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Function.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#include <tools/debug.hxx> +#include <connectivity/dbtools.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/property.hxx> +#include "Tools.hxx" +#include "corestrings.hrc" +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OFunction::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OFunction(xContext)); +} + +DBG_NAME( rpt_OFunction ) +// ----------------------------------------------------------------------------- +OFunction::OFunction(uno::Reference< uno::XComponentContext > const & _xContext) +:FunctionBase(m_aMutex) +,FunctionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,m_xContext(_xContext) +,m_bPreEvaluated(sal_False) +,m_bDeepTraversing(sal_False) +{ + m_sInitialFormula.IsPresent = sal_False; + DBG_CTOR( rpt_OFunction,NULL); +} +// ----------------------------------------------------------------------------- +OFunction::~OFunction() +{ + DBG_DTOR( rpt_OFunction,NULL); +} +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2(OFunction,FunctionBase,FunctionPropertySet) +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::dispose() throw(uno::RuntimeException) +{ + FunctionPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OFunction::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFunction")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFunction::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OFunction::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_FUNCTION; + + return aServices; +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OFunction::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OFunction::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OFunction::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return FunctionPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + FunctionPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFunction::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return FunctionPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FunctionPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FunctionPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FunctionPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + FunctionPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// report::XFunction: +::sal_Bool SAL_CALL OFunction::getPreEvaluated() throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_bPreEvaluated; +} +// ----------------------------------------------------------------------------- + +void SAL_CALL OFunction::setPreEvaluated(::sal_Bool the_value) throw (uno::RuntimeException) +{ + set(PROPERTY_PREEVALUATED,the_value,m_bPreEvaluated); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFunction::getDeepTraversing() throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_bDeepTraversing; +} +// ----------------------------------------------------------------------------- + +void SAL_CALL OFunction::setDeepTraversing(::sal_Bool the_value) throw (uno::RuntimeException) +{ + set(PROPERTY_DEEPTRAVERSING,the_value,m_bDeepTraversing); +} +// ----------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OFunction::getName() throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_sName; +} +// ----------------------------------------------------------------------------- + +void SAL_CALL OFunction::setName(const ::rtl::OUString & the_value) throw (uno::RuntimeException) +{ + set(PROPERTY_NAME,the_value,m_sName); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OFunction::getFormula() throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_sFormula; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::setFormula(const ::rtl::OUString & the_value) throw (uno::RuntimeException) +{ + set(PROPERTY_FORMULA,the_value,m_sFormula); +} +// ----------------------------------------------------------------------------- +beans::Optional< ::rtl::OUString> SAL_CALL OFunction::getInitialFormula() throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_sInitialFormula; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::setInitialFormula(const beans::Optional< ::rtl::OUString> & the_value) throw (uno::RuntimeException) +{ + set(PROPERTY_INITIALFORMULA,the_value,m_sInitialFormula); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OFunction::getParent( ) throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_xParent; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunction::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + if ( Parent.is() ) + { + uno::Reference< report::XFunctions> xFunctions(Parent,uno::UNO_QUERY_THROW); + m_xParent = xFunctions; + } + else + m_xParent = uno::WeakReference< report::XFunctions >(); +} +// ----------------------------------------------------------------------------- + +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/Functions.cxx b/reportdesign/source/core/api/Functions.cxx new file mode 100644 index 000000000000..9ae266d254c3 --- /dev/null +++ b/reportdesign/source/core/api/Functions.cxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Functions.hxx" +#include "Function.hxx" +#include <tools/debug.hxx> +#include "core_resource.hxx" +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include <comphelper/property.hxx> +#include <boost/bind.hpp> +#include <algorithm> +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; +DBG_NAME( rpt_OFunctions ) +// ----------------------------------------------------------------------------- +OFunctions::OFunctions(const uno::Reference< report::XFunctionsSupplier >& _xParent,const uno::Reference< uno::XComponentContext >& context) +:FunctionsBase(m_aMutex) +,m_aContainerListeners(m_aMutex) +,m_xContext(context) +,m_xParent(_xParent) +{ + DBG_CTOR( rpt_OFunctions,NULL); +} +//-------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +OFunctions::~OFunctions() +{ + DBG_DTOR( rpt_OFunctions,NULL); +} +//-------------------------------------------------------------------------- +void SAL_CALL OFunctions::dispose() throw(uno::RuntimeException) +{ + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +void SAL_CALL OFunctions::disposing() +{ + ::std::for_each(m_aFunctions.begin(),m_aFunctions.end(),::boost::mem_fn(&com::sun::star::report::XFunction::dispose)); + m_aFunctions.clear(); + lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aContainerListeners.disposeAndClear( aDisposeEvent ); + m_xContext.clear(); +} +// ----------------------------------------------------------------------------- +// XFunctionsSupplier +// ----------------------------------------------------------------------------- +uno::Reference< report::XFunction > SAL_CALL OFunctions::createFunction( ) throw (uno::RuntimeException) +{ + return new OFunction(m_xContext); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OFunctions::insertByIndex( ::sal_Int32 Index, const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + { + ::osl::MutexGuard aGuard(m_aMutex); + sal_Bool bAdd = (Index == static_cast<sal_Int32>(m_aFunctions.size())); + if ( !bAdd ) + checkIndex(Index); + uno::Reference< report::XFunction > xFunction(aElement,uno::UNO_QUERY); + if ( !xFunction.is() ) + throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_xContext->getServiceManager()),*this,2); + + if ( bAdd ) + m_aFunctions.push_back(xFunction); + else + { + TFunctions::iterator aPos = m_aFunctions.begin(); + ::std::advance(aPos,Index); + m_aFunctions.insert(aPos, xFunction); + } + xFunction->setParent(*this); + } + // notify our container listeners + container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), aElement, uno::Any()); + m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OFunctions::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Reference< report::XFunction > xFunction; + { + ::osl::MutexGuard aGuard(m_aMutex); + checkIndex(Index); + TFunctions::iterator aPos = m_aFunctions.begin(); + ::std::advance(aPos,Index); + xFunction = *aPos; + m_aFunctions.erase(aPos); + xFunction->setParent(NULL); + } + container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), uno::makeAny(xFunction), uno::Any()); + m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OFunctions::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Any aOldElement; + { + ::osl::MutexGuard aGuard(m_aMutex); + checkIndex(Index); + uno::Reference< report::XFunction > xFunction(Element,uno::UNO_QUERY); + if ( !xFunction.is() ) + throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_xContext->getServiceManager()),*this,2); + TFunctions::iterator aPos = m_aFunctions.begin(); + ::std::advance(aPos,Index); + aOldElement <<= *aPos; + *aPos = xFunction; + } + + container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), Element, aOldElement); + m_aContainerListeners.notifyEach(&container::XContainerListener::elementReplaced,aEvent); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OFunctions::getCount( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aFunctions.size(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OFunctions::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkIndex(Index); + TFunctions::iterator aPos = m_aFunctions.begin(); + ::std::advance(aPos,Index); + return uno::makeAny(*aPos); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OFunctions::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XFunction>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OFunctions::hasElements( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return !m_aFunctions.empty(); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OFunctions::getParent( ) throw (uno::RuntimeException) +{ + return m_xParent; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunctions::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException) +{ + throw lang::NoSupportException(); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OFunctions::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aContainerListeners.addInterface(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OFunctions::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aContainerListeners.removeInterface(xListener); +} +// ----------------------------------------------------------------------------- +void OFunctions::checkIndex(sal_Int32 _nIndex) +{ + if ( _nIndex < 0 || static_cast<sal_Int32>(m_aFunctions.size()) <= _nIndex ) + throw lang::IndexOutOfBoundsException(); +} +// ============================================================================= +} +// ============================================================================= diff --git a/reportdesign/source/core/api/Group.cxx b/reportdesign/source/core/api/Group.cxx new file mode 100644 index 000000000000..8f5200746191 --- /dev/null +++ b/reportdesign/source/core/api/Group.cxx @@ -0,0 +1,357 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Group.hxx" +#include "Section.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/report/GroupOn.hpp> +#include <com/sun/star/report/KeepTogether.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include "core_resource.hxx" +#include "Tools.hxx" +#include <tools/debug.hxx> +#include <comphelper/property.hxx> +#include "Functions.hxx" + +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +DBG_NAME( rpt_OGroup ) +// ----------------------------------------------------------------------------- +OGroup::OGroup(const uno::Reference< report::XGroups >& _xParent + ,const uno::Reference< uno::XComponentContext >& _xContext) +:GroupBase(m_aMutex) +,GroupPropertySet(_xContext,static_cast< GroupPropertySet::Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,m_xContext(_xContext) +,m_xParent(_xParent) +{ + DBG_CTOR( rpt_OGroup,NULL); + osl_incrementInterlockedCount(&m_refCount); + { + m_xFunctions = new OFunctions(this,m_xContext); + } + osl_decrementInterlockedCount( &m_refCount ); +} +//-------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +OGroup::~OGroup() +{ + DBG_DTOR( rpt_OGroup,NULL); +} +//-------------------------------------------------------------------------- +void OGroup::copyGroup(const uno::Reference< report::XGroup >& _xSource) +{ + ::comphelper::copyProperties(_xSource.get(),static_cast<GroupPropertySet*>(this)); + + if ( _xSource->getHeaderOn() ) + { + setHeaderOn(sal_True); + OSection::lcl_copySection(_xSource->getHeader(),m_xHeader); + } // if ( _xSource->getHeaderOn() ) + + if ( _xSource->getFooterOn() ) + { + setFooterOn(sal_True); + OSection::lcl_copySection(_xSource->getFooter(),m_xFooter); + } // if ( _xSource->getFooterOn() ) +} +//-------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2(OGroup,GroupBase,GroupPropertySet) +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OGroup::getImplementationName( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Group")); +} +//------------------------------------------------------------------------------ +uno::Sequence< ::rtl::OUString> OGroup::getSupportedServiceNames_Static(void) throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString> aSupported(1); + aSupported.getArray()[0] = SERVICE_GROUP; + return aSupported; +} +//------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString> SAL_CALL OGroup::getSupportedServiceNames() throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OGroup::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException) +{ + return ::comphelper::existsValue(_rServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::dispose() throw(uno::RuntimeException) +{ + GroupPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +void SAL_CALL OGroup::disposing() +{ + m_xHeader.clear(); + m_xFooter.clear(); + //::comphelper::disposeComponent(m_xHeader); + //::comphelper::disposeComponent(m_xFooter); + ::comphelper::disposeComponent(m_xFunctions); + m_xContext.clear(); +} +// ----------------------------------------------------------------------------- +// XGroup +::sal_Bool SAL_CALL OGroup::getSortAscending() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_eSortAscending; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setSortAscending( ::sal_Bool _sortascending ) throw (uno::RuntimeException) +{ + set(PROPERTY_SORTASCENDING,_sortascending,m_aProps.m_eSortAscending); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OGroup::getHeaderOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_xHeader.is(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setHeaderOn( ::sal_Bool _headeron ) throw (uno::RuntimeException) +{ + if ( _headeron != m_xHeader.is() ) + { + ::rtl::OUString sName(RPT_RESSTRING(RID_STR_GROUP_HEADER,m_xContext->getServiceManager())); + /*const ::rtl::OUString sPlaceHolder(RTL_CONSTASCII_USTRINGPARAM("%1")); + sName = sName.replaceAt(sName.indexOf(sPlaceHolder),sPlaceHolder.getLength(),m_aProps.m_sExpression);*/ + setSection(PROPERTY_HEADERON,_headeron,sName,m_xHeader); + } +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OGroup::getFooterOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_xFooter.is(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setFooterOn( ::sal_Bool _footeron ) throw (uno::RuntimeException) +{ + if ( _footeron != m_xFooter.is() ) + { + ::rtl::OUString sName(RPT_RESSTRING(RID_STR_GROUP_FOOTER,m_xContext->getServiceManager())); + /*const ::rtl::OUString sPlaceHolder(RTL_CONSTASCII_USTRINGPARAM("%1")); + sName = sName.replaceAt(sName.indexOf(sPlaceHolder),sPlaceHolder.getLength(),m_aProps.m_sExpression);*/ + setSection(PROPERTY_FOOTERON,_footeron,sName,m_xFooter); + } +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OGroup::getHeader() throw (container::NoSuchElementException, uno::RuntimeException) +{ + uno::Reference< report::XSection > xRet; + { + ::osl::MutexGuard aGuard(m_aMutex); + xRet = m_xHeader; + } + + if ( !xRet.is() ) + throw container::NoSuchElementException(); + return xRet; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OGroup::getFooter() throw (container::NoSuchElementException, uno::RuntimeException) +{ + uno::Reference< report::XSection > xRet; + { + ::osl::MutexGuard aGuard(m_aMutex); + xRet = m_xFooter; + } + + if ( !xRet.is() ) + throw container::NoSuchElementException(); + return xRet; +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OGroup::getGroupOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_nGroupOn; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setGroupOn( ::sal_Int16 _groupon ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + if ( _groupon < report::GroupOn::DEFAULT || _groupon > report::GroupOn::INTERVAL ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::GroupOn")) + ,*this + ,1 + ,m_xContext); + set(PROPERTY_GROUPON,_groupon,m_aProps.m_nGroupOn); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OGroup::getGroupInterval() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_nGroupInterval; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setGroupInterval( ::sal_Int32 _groupinterval ) throw (uno::RuntimeException) +{ + set(PROPERTY_GROUPINTERVAL,_groupinterval,m_aProps.m_nGroupInterval); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OGroup::getKeepTogether() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_nKeepTogether; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setKeepTogether( ::sal_Int16 _keeptogether ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + if ( _keeptogether < report::KeepTogether::NO || _keeptogether > report::KeepTogether::WITH_FIRST_DETAIL ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::KeepTogether")) + ,*this + ,1 + ,m_xContext); + set(PROPERTY_KEEPTOGETHER,_keeptogether,m_aProps.m_nKeepTogether); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XGroups > SAL_CALL OGroup::getGroups() throw (uno::RuntimeException) +{ + return m_xParent; +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OGroup::getExpression() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_sExpression; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setExpression( const ::rtl::OUString& _expression ) throw (uno::RuntimeException) +{ + set(PROPERTY_EXPRESSION,_expression,m_aProps.m_sExpression); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OGroup::getStartNewColumn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_bStartNewColumn; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setStartNewColumn( ::sal_Bool _startnewcolumn ) throw (uno::RuntimeException) +{ + set(PROPERTY_STARTNEWCOLUMN,_startnewcolumn,m_aProps.m_bStartNewColumn); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OGroup::getResetPageNumber() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.m_bResetPageNumber; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setResetPageNumber( ::sal_Bool _resetpagenumber ) throw (uno::RuntimeException) +{ + set(PROPERTY_RESETPAGENUMBER,_resetpagenumber,m_aProps.m_bResetPageNumber); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OGroup::getParent( ) throw (uno::RuntimeException) +{ + return m_xParent; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException) +{ + throw lang::NoSupportException(); +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + // return uno::Reference< beans::XPropertySetInfo >(); + return GroupPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + GroupPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OGroup::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return GroupPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + GroupPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + GroupPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + GroupPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroup::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + GroupPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void OGroup::setSection( const ::rtl::OUString& _sProperty + ,const sal_Bool& _bOn + ,const ::rtl::OUString& _sName + ,uno::Reference< report::XSection>& _member) +{ + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l); + lcl_createSectionIfNeeded(_bOn ,this,_member); + if ( _member.is() ) + _member->setName(_sName); + } + l.notify(); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XFunctions > SAL_CALL OGroup::getFunctions() throw (uno::RuntimeException) +{ + return m_xFunctions; +} +// ============================================================================= +} // namespace reportdesign +// ============================================================================= + diff --git a/reportdesign/source/core/api/Groups.cxx b/reportdesign/source/core/api/Groups.cxx new file mode 100644 index 000000000000..f180471de400 --- /dev/null +++ b/reportdesign/source/core/api/Groups.cxx @@ -0,0 +1,217 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Groups.hxx" +#include "Group.hxx" +#include <tools/debug.hxx> +#include "core_resource.hxx" +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include <boost/bind.hpp> +#include <algorithm> +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; +DBG_NAME( rpt_OGroups ) +// ----------------------------------------------------------------------------- +OGroups::OGroups(const uno::Reference< report::XReportDefinition >& _xParent,const uno::Reference< uno::XComponentContext >& context) +:GroupsBase(m_aMutex) +,m_aContainerListeners(m_aMutex) +,m_xContext(context) +,m_xParent(_xParent) +{ + DBG_CTOR( rpt_OGroups,NULL); +} +//-------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +OGroups::~OGroups() +{ + DBG_DTOR( rpt_OGroups,NULL); +} +//-------------------------------------------------------------------------- +void OGroups::copyGroups(const uno::Reference< report::XGroups >& _xSource) +{ + sal_Int32 nCount = _xSource->getCount(); + for (sal_Int32 i = 0; i != nCount; ++i) + { + OGroup* pGroup = new OGroup(this,m_xContext); + m_aGroups.push_back(pGroup); + uno::Reference<report::XGroup> xGroup(_xSource->getByIndex(i),uno::UNO_QUERY); + pGroup->copyGroup(xGroup); + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroups::dispose() throw(uno::RuntimeException) +{ + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +void SAL_CALL OGroups::disposing() +{ + ::std::for_each(m_aGroups.begin(),m_aGroups.end(),::boost::mem_fn(&com::sun::star::report::XGroup::dispose)); + m_aGroups.clear(); + lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aContainerListeners.disposeAndClear( aDisposeEvent ); + m_xContext.clear(); +} +// ----------------------------------------------------------------------------- +// XGroups +uno::Reference< report::XReportDefinition > SAL_CALL OGroups::getReportDefinition() throw (uno::RuntimeException) +{ + return m_xParent; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XGroup > SAL_CALL OGroups::createGroup( ) throw (uno::RuntimeException) +{ + return new OGroup(this,m_xContext); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OGroups::insertByIndex( ::sal_Int32 Index, const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + { + ::osl::MutexGuard aGuard(m_aMutex); + sal_Bool bAdd = (Index == static_cast<sal_Int32>(m_aGroups.size())); + if ( !bAdd ) + checkIndex(Index); + uno::Reference< report::XGroup > xGroup(aElement,uno::UNO_QUERY); + if ( !xGroup.is() ) + throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_xContext->getServiceManager()),*this,2); + + if ( bAdd ) + m_aGroups.push_back(xGroup); + else + { + TGroups::iterator aPos = m_aGroups.begin(); + ::std::advance(aPos,Index); + m_aGroups.insert(aPos, xGroup); + } + } + // notify our container listeners + container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), aElement, uno::Any()); + m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OGroups::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Reference< report::XGroup > xGroup; + { + ::osl::MutexGuard aGuard(m_aMutex); + checkIndex(Index); + TGroups::iterator aPos = m_aGroups.begin(); + ::std::advance(aPos,Index); + xGroup = *aPos; + m_aGroups.erase(aPos); + } + container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), uno::makeAny(xGroup), uno::Any()); + m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OGroups::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Any aOldElement; + { + ::osl::MutexGuard aGuard(m_aMutex); + checkIndex(Index); + uno::Reference< report::XGroup > xGroup(Element,uno::UNO_QUERY); + if ( !xGroup.is() ) + throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_xContext->getServiceManager()),*this,2); + TGroups::iterator aPos = m_aGroups.begin(); + ::std::advance(aPos,Index); + aOldElement <<= *aPos; + *aPos = xGroup; + } + + container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), Element, aOldElement); + m_aContainerListeners.notifyEach(&container::XContainerListener::elementReplaced,aEvent); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OGroups::getCount( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aGroups.size(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OGroups::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkIndex(Index); + TGroups::iterator aPos = m_aGroups.begin(); + ::std::advance(aPos,Index); + return uno::makeAny(*aPos); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OGroups::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XGroup>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OGroups::hasElements( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return !m_aGroups.empty(); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OGroups::getParent( ) throw (uno::RuntimeException) +{ + return m_xParent; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroups::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException) +{ + throw lang::NoSupportException(); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OGroups::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aContainerListeners.addInterface(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OGroups::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aContainerListeners.removeInterface(xListener); +} +// ----------------------------------------------------------------------------- +void OGroups::checkIndex(sal_Int32 _nIndex) +{ + if ( _nIndex < 0 || static_cast<sal_Int32>(m_aGroups.size()) <= _nIndex ) + throw lang::IndexOutOfBoundsException(); +} +// ============================================================================= +} +// ============================================================================= diff --git a/reportdesign/source/core/api/ImageControl.cxx b/reportdesign/source/core/api/ImageControl.cxx new file mode 100644 index 000000000000..131c5e372aa5 --- /dev/null +++ b/reportdesign/source/core/api/ImageControl.cxx @@ -0,0 +1,505 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ImageControl.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include "core_resource.hxx" +#include <comphelper/sequence.hxx> +#include "Tools.hxx" +#include <tools/debug.hxx> +#include <comphelper/property.hxx> +#include "FormatCondition.hxx" +#include <com/sun/star/awt/ImageScaleMode.hpp> +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include "ReportHelperImpl.hxx" +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +uno::Sequence< ::rtl::OUString > lcl_getImageOptionals() +{ + ::rtl::OUString pProps[] = { + PROPERTY_CHARCOLOR + ,PROPERTY_CHAREMPHASIS + ,PROPERTY_CHARFONTCHARSET + ,PROPERTY_CHARFONTFAMILY + ,PROPERTY_CHARFONTNAME + ,PROPERTY_CHARFONTPITCH + ,PROPERTY_CHARFONTSTYLENAME + ,PROPERTY_CHARHEIGHT + ,PROPERTY_CHARPOSTURE + ,PROPERTY_CHARRELIEF + ,PROPERTY_FONTDESCRIPTOR + ,PROPERTY_FONTDESCRIPTORASIAN + ,PROPERTY_FONTDESCRIPTORCOMPLEX + ,PROPERTY_CONTROLTEXTEMPHASISMARK + ,PROPERTY_CHARROTATION + ,PROPERTY_CHARSCALEWIDTH + ,PROPERTY_CHARSTRIKEOUT + ,PROPERTY_CHARUNDERLINECOLOR + ,PROPERTY_CHARUNDERLINE + ,PROPERTY_CHARWEIGHT + ,PROPERTY_CHARWORDMODE + ,PROPERTY_CHARFLASH + ,PROPERTY_CHARAUTOKERNING + ,PROPERTY_CHARESCAPEMENTHEIGHT + ,PROPERTY_CHARLOCALE + ,PROPERTY_CHARESCAPEMENT + ,PROPERTY_CHARCASEMAP + ,PROPERTY_CHARCOMBINEISON + ,PROPERTY_CHARCOMBINEPREFIX + ,PROPERTY_CHARCOMBINESUFFIX + ,PROPERTY_CHARHIDDEN + ,PROPERTY_CHARSHADOWED + ,PROPERTY_CHARCONTOURED + ,PROPERTY_VISITEDCHARSTYLENAME + ,PROPERTY_UNVISITEDCHARSTYLENAME + ,PROPERTY_CHARKERNING + ,PROPERTY_MASTERFIELDS + ,PROPERTY_DETAILFIELDS + ,PROPERTY_PARAADJUST + , PROPERTY_CHAREMPHASISASIAN + , PROPERTY_CHARFONTNAMEASIAN + , PROPERTY_CHARFONTSTYLENAMEASIAN + , PROPERTY_CHARFONTFAMILYASIAN + , PROPERTY_CHARFONTCHARSETASIAN + , PROPERTY_CHARFONTPITCHASIAN + , PROPERTY_CHARHEIGHTASIAN + , PROPERTY_CHARUNDERLINEASIAN + , PROPERTY_CHARWEIGHTASIAN + , PROPERTY_CHARPOSTUREASIAN + , PROPERTY_CHARWORDMODEASIAN + , PROPERTY_CHARROTATIONASIAN + , PROPERTY_CHARSCALEWIDTHASIAN + , PROPERTY_CHARLOCALEASIAN + , PROPERTY_CHAREMPHASISCOMPLEX + , PROPERTY_CHARFONTNAMECOMPLEX + , PROPERTY_CHARFONTSTYLENAMECOMPLEX + , PROPERTY_CHARFONTFAMILYCOMPLEX + , PROPERTY_CHARFONTCHARSETCOMPLEX + , PROPERTY_CHARFONTPITCHCOMPLEX + , PROPERTY_CHARHEIGHTCOMPLEX + , PROPERTY_CHARUNDERLINECOMPLEX + , PROPERTY_CHARWEIGHTCOMPLEX + , PROPERTY_CHARPOSTURECOMPLEX + , PROPERTY_CHARWORDMODECOMPLEX + , PROPERTY_CHARROTATIONCOMPLEX + , PROPERTY_CHARSCALEWIDTHCOMPLEX + , PROPERTY_CHARLOCALECOMPLEX + + }; + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} + +DBG_NAME( rpt_OImageControl ) +// ----------------------------------------------------------------------------- +OImageControl::OImageControl(uno::Reference< uno::XComponentContext > const & _xContext) +:ImageControlBase(m_aMutex) +,ImageControlPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getImageOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nScaleMode(awt::ImageScaleMode::None) +,m_bPreserveIRI(sal_True) +{ + DBG_CTOR( rpt_OImageControl,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_IMAGECONTROL,m_aProps.aComponent.m_xContext->getServiceManager()); +} +// ----------------------------------------------------------------------------- +OImageControl::OImageControl(uno::Reference< uno::XComponentContext > const & _xContext + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,uno::Reference< drawing::XShape >& _xShape) +:ImageControlBase(m_aMutex) +,ImageControlPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getImageOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nScaleMode(awt::ImageScaleMode::None) +,m_bPreserveIRI(sal_True) +{ + DBG_CTOR( rpt_OImageControl,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_IMAGECONTROL,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_xFactory = _xFactory; + osl_incrementInterlockedCount( &m_refCount ); + { + m_aProps.aComponent.setShape(_xShape,this,m_refCount); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OImageControl::~OImageControl() +{ + DBG_DTOR( rpt_OImageControl,NULL); +} +// ----------------------------------------------------------------------------- +//IMPLEMENT_FORWARD_XINTERFACE2(OImageControl,ImageControlBase,ImageControlPropertySet) +IMPLEMENT_FORWARD_REFCOUNT( OImageControl, ImageControlBase ) +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OImageControl::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = ImageControlBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = ImageControlPropertySet::queryInterface(_rType); + + if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) + return aReturn; + + return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::dispose() throw(uno::RuntimeException) +{ + ImageControlPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OImageControl::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OImageControl")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OImageControl::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OImageControl::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_IMAGECONTROL; + + return aServices; +} +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OImageControl::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OImageControl(xContext)); +} + +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OImageControl::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OImageControl::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +// XReportComponent +REPORTCOMPONENT_IMPL(OImageControl,m_aProps.aComponent) +REPORTCOMPONENT_IMPL2(OImageControl,m_aProps.aComponent) +REPORTCOMPONENT_NOMASTERDETAIL(OImageControl) +//REPORTCONTROLFORMAT_IMPL(OImageControl,m_aProps.aFormatProperties) +NO_REPORTCONTROLFORMAT_IMPL(OImageControl) +::rtl::OUString SAL_CALL OImageControl::getHyperLinkURL() throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aFormatProperties.sHyperLinkURL; +} +void SAL_CALL OImageControl::setHyperLinkURL(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + set(PROPERTY_HYPERLINKURL,the_value,m_aProps.aFormatProperties.sHyperLinkURL); +} +::rtl::OUString SAL_CALL OImageControl::getHyperLinkTarget() throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aFormatProperties.sHyperLinkTarget; +} +void SAL_CALL OImageControl::setHyperLinkTarget(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + set(PROPERTY_HYPERLINKTARGET,the_value,m_aProps.aFormatProperties.sHyperLinkTarget); +} +::rtl::OUString SAL_CALL OImageControl::getHyperLinkName() throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aFormatProperties.sHyperLinkName; +} +void SAL_CALL OImageControl::setHyperLinkName(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + set(PROPERTY_HYPERLINKNAME,the_value,m_aProps.aFormatProperties.sHyperLinkName); +} + +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OImageControl::getControlBackground() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aFormatProperties.m_bBackgroundTransparent ? COL_TRANSPARENT : m_aProps.aFormatProperties.nBackgroundColor; +} + +void SAL_CALL OImageControl::setControlBackground( ::sal_Int32 _backgroundcolor ) throw (uno::RuntimeException, beans::UnknownPropertyException) +{ + sal_Bool bTransparent = _backgroundcolor == static_cast<sal_Int32>(COL_TRANSPARENT); + setControlBackgroundTransparent(bTransparent); + if ( !bTransparent ) + set(PROPERTY_CONTROLBACKGROUND,_backgroundcolor,m_aProps.aFormatProperties.nBackgroundColor); +} + +::sal_Bool SAL_CALL OImageControl::getControlBackgroundTransparent() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aFormatProperties.m_bBackgroundTransparent; +} + +void SAL_CALL OImageControl::setControlBackgroundTransparent( ::sal_Bool _controlbackgroundtransparent ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_CONTROLBACKGROUNDTRANSPARENT,_controlbackgroundtransparent,m_aProps.aFormatProperties.m_bBackgroundTransparent); + if ( _controlbackgroundtransparent ) + set(PROPERTY_CONTROLBACKGROUND,static_cast<sal_Int32>(COL_TRANSPARENT),m_aProps.aFormatProperties.nBackgroundColor); +} + +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OImageControl::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return ImageControlPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + ImageControlPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OImageControl::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return ImageControlPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ImageControlPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ImageControlPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ImageControlPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ImageControlPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XReportControlModel +::rtl::OUString SAL_CALL OImageControl::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aDataField; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setDataField( const ::rtl::OUString& _datafield ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_DATAFIELD,_datafield,m_aProps.aDataField); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OImageControl::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.bPrintWhenGroupChange; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OImageControl::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aConditionalPrintExpression; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression); +} + +// ----------------------------------------------------------------------------- + +// XCloneable +uno::Reference< util::XCloneable > SAL_CALL OImageControl::createClone( ) throw (uno::RuntimeException) +{ + uno::Reference< report::XReportComponent> xSource = this; + uno::Reference< report::XImageControl> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_IMAGECONTROL),uno::UNO_QUERY_THROW); + return xSet.get(); +} +// ----------------------------------------------------------------------------- + +// XImageControl +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OImageControl::getImageURL() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aImageURL; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setImageURL( const ::rtl::OUString& _imageurl ) throw (uno::RuntimeException) +{ + set(PROPERTY_IMAGEURL,_imageurl,m_aImageURL); +} +// ----------------------------------------------------------------------------- +uno::Reference< awt::XImageProducer > SAL_CALL OImageControl::getImageProducer( ) throw (uno::RuntimeException) +{ + return uno::Reference< awt::XImageProducer >(); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OImageControl::getParent( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getParent(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + OShapeHelper::setParent(Parent,this); +} +uno::Reference< report::XFormatCondition > SAL_CALL OImageControl::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException) +{ + return new OFormatCondition(m_aProps.aComponent.m_xContext); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OImageControl::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.addContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.removeContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OImageControl::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OImageControl::hasElements( ) throw (uno::RuntimeException) +{ + return m_aProps.hasElements(); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OImageControl::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.insertByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.removeByIndex(Index); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OImageControl::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.replaceByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OImageControl::getCount( ) throw (uno::RuntimeException) +{ + return m_aProps.getCount(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OImageControl::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_aProps.getByIndex( Index ); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// XShape +awt::Point SAL_CALL OImageControl::getPosition( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getPosition(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) +{ + OShapeHelper::setPosition(aPosition,this); +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OImageControl::getSize( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getSize(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + OShapeHelper::setSize(aSize,this); +} +// ----------------------------------------------------------------------------- + +// XShapeDescriptor +::rtl::OUString SAL_CALL OImageControl::getShapeType( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_aProps.aComponent.m_xShape.is() ) + return m_aProps.aComponent.m_xShape->getShapeType(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OImageControl::getScaleMode() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_nScaleMode; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setScaleMode( ::sal_Int16 _scalemode ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + if ( _scalemode < awt::ImageScaleMode::None ||_scalemode > awt::ImageScaleMode::Anisotropic ) + throw lang::IllegalArgumentException(); + set(PROPERTY_SCALEMODE,_scalemode,m_nScaleMode); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OImageControl::getPreserveIRI() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_bPreserveIRI; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OImageControl::setPreserveIRI( ::sal_Bool _preserveiri ) throw (uno::RuntimeException) +{ + set(PROPERTY_PRESERVEIRI,_preserveiri,m_bPreserveIRI); +} +// ============================================================================= +} // namespace reportdesign +// ============================================================================= + diff --git a/reportdesign/source/core/api/ReportComponent.cxx b/reportdesign/source/core/api/ReportComponent.cxx new file mode 100644 index 000000000000..f9ab9471ce3b --- /dev/null +++ b/reportdesign/source/core/api/ReportComponent.cxx @@ -0,0 +1,153 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ReportComponent.hxx" + +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontWidth.hpp> +#include "ReportControlModel.hxx" +#include <com/sun/star/reflection/XProxyFactory.hpp> +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <editeng/unolingu.hxx> +#include <unotools/syslocale.hxx> +#include <unotools/lingucfg.hxx> +#include <i18npool/mslangid.hxx> + +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; + +void lcl_getDefaultFonts( Font& rLatinFont, Font& rCJKFont, Font& rCTLFont,LanguageType _eLatin,LanguageType _eCJK,LanguageType _eCTL ) +{ + LanguageType eLatin = _eLatin; + + // #108374# / #107782#: If the UI language is Korean, the default Latin font has to + // be queried for Korean, too (the Latin language from the document can't be Korean). + // This is the same logic as in SwDocShell::InitNew. + LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); + switch( eUiLanguage ) + { + case LANGUAGE_KOREAN: + case LANGUAGE_KOREAN_JOHAB: + eLatin = eUiLanguage; + break; + } + + rLatinFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION, eLatin, DEFAULTFONT_FLAGS_ONLYONE ); + rCJKFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION, _eCJK, DEFAULTFONT_FLAGS_ONLYONE ); + rCTLFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_PRESENTATION, _eCTL, DEFAULTFONT_FLAGS_ONLYONE ) ; +} +OFormatProperties::OFormatProperties() + :nAlign(style::ParagraphAdjust_LEFT) + ,nFontEmphasisMark(0) + ,nFontRelief(0) + ,nTextColor(0) + ,nTextLineColor(0) + ,nCharUnderlineColor(0xFFFFFFFF) + ,nBackgroundColor(COL_TRANSPARENT) + ,aVerticalAlignment( style::VerticalAlignment_TOP ) + ,nCharEscapement(0) + ,nCharCaseMap(0) + ,nCharKerning(0) + ,nCharEscapementHeight(100) + ,m_bBackgroundTransparent(sal_True) + ,bCharFlash(sal_False) + ,bCharAutoKerning(sal_False) + ,bCharCombineIsOn(sal_False) + ,bCharHidden(sal_False) + ,bCharShadowed(sal_False) + ,bCharContoured(sal_False) +{ + try + { + SvtLinguConfig aLinguConfig; + using namespace ::com::sun::star::i18n::ScriptType; + + aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale"))) >>= aCharLocale; + LanguageType eCurLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocale), LATIN); + aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CJK"))) >>= aCharLocaleAsian; + LanguageType eCurLangCJK = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocaleAsian), ASIAN); + aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CTL"))) >>= aCharLocaleComplex; + LanguageType eCurLangCTL = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocaleComplex), COMPLEX); + + Font aLatin,aCJK,aCTL; + lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL); + aFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aLatin); + aAsianFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCJK); + aComplexFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCTL); + } + catch(const uno::Exception&) + { + } + aFontDescriptor.Weight = awt::FontWeight::NORMAL; + aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL; + // aCharLocale = SvtSysLocale().GetLocaleData().getLocale(); +} +// ----------------------------------------------------------------------------- +void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount) +{ + osl_incrementInterlockedCount( &_rRefCount ); + { + m_xProxy.set(_xShape,uno::UNO_QUERY); + ::comphelper::query_aggregation(m_xProxy,m_xShape); + ::comphelper::query_aggregation(m_xProxy,m_xProperty); + _xShape.clear(); + m_xTypeProvider.set(m_xShape,uno::UNO_QUERY); + m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY); + m_xServiceInfo.set(m_xShape,uno::UNO_QUERY); + + // set ourself as delegator + if ( m_xProxy.is() ) + m_xProxy->setDelegator( _xTunnel ); + } + osl_decrementInterlockedCount( &_rRefCount ); +} +// ----------------------------------------------------------------------------- +OReportComponentProperties::~OReportComponentProperties() +{ + if ( m_xProxy.is() ) + { + m_xProxy->setDelegator( NULL ); + m_xProxy.clear(); + } +} +// ============================================================================= +} // namespace reportdesign +// ============================================================================= + + diff --git a/reportdesign/source/core/api/ReportControlModel.cxx b/reportdesign/source/core/api/ReportControlModel.cxx new file mode 100644 index 000000000000..8d97f7abada0 --- /dev/null +++ b/reportdesign/source/core/api/ReportControlModel.cxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ReportControlModel.hxx" +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +namespace reportdesign +{ +using namespace com::sun::star; +using namespace comphelper; + +bool operator==( const ::com::sun::star::awt::FontDescriptor& _lhs, const ::com::sun::star::awt::FontDescriptor& _rhs ) +{ + return ( _lhs.Name == _rhs.Name ) + && ( _lhs.Height == _rhs.Height ) + && ( _lhs.Width == _rhs.Width ) + && ( _lhs.StyleName == _rhs.StyleName ) + && ( _lhs.Family == _rhs.Family ) + && ( _lhs.CharSet == _rhs.CharSet ) + && ( _lhs.Pitch == _rhs.Pitch ) + && ( _lhs.CharacterWidth == _rhs.CharacterWidth ) + && ( _lhs.Weight == _rhs.Weight ) + && ( _lhs.Slant == _rhs.Slant ) + && ( _lhs.Underline == _rhs.Underline ) + && ( _lhs.Strikeout == _rhs.Strikeout ) + && ( _lhs.Orientation == _rhs.Orientation ) + && ( _lhs.Kerning == _rhs.Kerning ) + && ( _lhs.WordLineMode == _rhs.WordLineMode ) + && ( _lhs.Type == _rhs.Type ); +} + +// ----------------------------------------------------------------------------- +// XContainer +void OReportControlModel::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + aContainerListeners.addInterface(xListener); +} +// ----------------------------------------------------------------------------- +void OReportControlModel::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + aContainerListeners.removeInterface(xListener); +} +// ----------------------------------------------------------------------------- +::sal_Bool OReportControlModel::hasElements( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + return !m_aFormatConditions.empty(); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void OReportControlModel::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Reference<report::XFormatCondition> xElement(Element,uno::UNO_QUERY); + if ( !xElement.is() ) + throw lang::IllegalArgumentException(); + + uno::Reference< container::XContainer > xBroadcaster; + { + ::osl::MutexGuard aGuard(m_rMutex); + xBroadcaster = m_pOwner; + if ( Index > static_cast<sal_Int32>(m_aFormatConditions.size()) ) + throw lang::IndexOutOfBoundsException(); + + //m_aFormatConditions.resize(m_aFormatConditions.size() + 1); + m_aFormatConditions.insert(m_aFormatConditions.begin() + Index,xElement); + } + + // notify our container listeners + container::ContainerEvent aEvent(xBroadcaster, uno::makeAny(Index), Element, uno::Any()); + aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent); +} +// ----------------------------------------------------------------------------- +void OReportControlModel::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Any Element; + uno::Reference< container::XContainer > xBroadcaster; + { + ::osl::MutexGuard aGuard(m_rMutex); + xBroadcaster = m_pOwner; + checkIndex(Index); + Element <<= m_aFormatConditions[Index]; + m_aFormatConditions.erase(m_aFormatConditions.begin() + Index); + } + container::ContainerEvent aEvent(xBroadcaster, uno::makeAny(Index), Element, uno::Any()); + aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void OReportControlModel::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Reference<report::XFormatCondition> xElement(Element,uno::UNO_QUERY); + if ( !xElement.is() ) + throw lang::IllegalArgumentException(); + uno::Reference< container::XContainer > xBroadcaster; + { + ::osl::MutexGuard aGuard(m_rMutex); + xBroadcaster = m_pOwner; + checkIndex(Index); + m_aFormatConditions[Index] = xElement; + } + container::ContainerEvent aEvent(xBroadcaster, uno::makeAny(Index), Element, uno::Any()); + aContainerListeners.notifyEach(&container::XContainerListener::elementReplaced,aEvent); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 OReportControlModel::getCount( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + return m_aFormatConditions.size(); +} +// ----------------------------------------------------------------------------- +uno::Any OReportControlModel::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Any aElement; + { + ::osl::MutexGuard aGuard(m_rMutex); + checkIndex(Index); + aElement <<= m_aFormatConditions[Index]; + } + return aElement; +} +// ----------------------------------------------------------------------------- +void OReportControlModel::checkIndex(sal_Int32 _nIndex) +{ + if ( _nIndex < 0 || static_cast<sal_Int32>(m_aFormatConditions.size()) <= _nIndex ) + throw lang::IndexOutOfBoundsException(); +} +// ----------------------------------------------------------------------------- +bool OReportControlModel::isInterfaceForbidden(const uno::Type& _rType) +{ + return (_rType == ::getCppuType((const uno::Reference< beans::XPropertyState>* )0) || _rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet>* )0)); +} +// ----------------------------------------------------------------------------- +} // reportdesign + diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx new file mode 100644 index 000000000000..2cf848dc0c84 --- /dev/null +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -0,0 +1,2939 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ReportDefinition.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/report/GroupKeepTogether.hpp> +#include <com/sun/star/report/ReportPrintOption.hpp> +#include <com/sun/star/report/XFunction.hpp> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/table/BorderLine.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/style/PageStyleLayout.hpp> +#include <com/sun/star/style/GraphicLocation.hpp> +#include <com/sun/star/xml/AttributeData.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/documentconstants.hxx> +#include <comphelper/genericpropertyset.hxx> +#include <comphelper/mediadescriptor.hxx> +#include <comphelper/mimeconfighelper.hxx> +#include <comphelper/namecontainer.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/numberedcollection.hxx> +#include <comphelper/propertystatecontainer.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/property.hxx> +#include <comphelper/propertysetinfo.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/seqstream.hxx> +#include <comphelper/storagehelper.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp> +#include <vcl/svapp.hxx> +#include <vcl/virdev.hxx> +#include <vos/mutex.hxx> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/document/EventObject.hpp> +#include <com/sun/star/document/XEventListener.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/EmbedMapUnits.hpp> +#include <com/sun/star/embed/EntryInitModes.hpp> +#include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/embed/XEmbedPersist.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/ui/XUIConfigurationStorage.hpp> +#include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/task/ErrorCodeIOException.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include "corestrings.hrc" +#include "Groups.hxx" +#include "RptDef.hxx" +#include "Section.hxx" +#include "FixedLine.hxx" +#include "core_resource.hrc" +#include "core_resource.hxx" +#include "Tools.hxx" +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/streamwrap.hxx> +#include <connectivity/CommonTools.hxx> +#include <connectivity/dbconversion.hxx> +#include <framework/titlehelper.hxx> +#include <connectivity/dbtools.hxx> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include "Functions.hxx" +#include <boost/mem_fn.hpp> +#include <boost/bind.hpp> +#include <boost/utility.hpp> +#include <unotools/saveopt.hxx> +#include "RptModel.hxx" +#include "UndoEnv.hxx" +#include "FormattedField.hxx" +#include "FixedText.hxx" +#include "ImageControl.hxx" +#include "Shape.hxx" +#include "ReportHelperImpl.hxx" +#include <svl/itempool.hxx> +#include <unotools/moduleoptions.hxx> +#include <osl/thread.hxx> + +#include <editeng/paperinf.hxx> +#include <svx/svdlayer.hxx> +#include <svx/xmleohlp.hxx> +#include <svx/xmlgrhlp.hxx> +#include <svx/unofill.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <cppuhelper/exc_hlp.hxx> +#include "ReportComponent.hxx" +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> +#include <com/sun/star/style/NumberingType.hpp> + +#define MAP_LEN(x) x, sizeof(x) - 1 +#define MAP_CHAR_LEN(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) +// page styles +#define SC_UNO_PAGE_GRAPHICFILT "BackGraphicFilter" +#define SC_UNO_PAGE_LEFTBORDER "LeftBorder" +#define SC_UNO_PAGE_RIGHTBORDER "RightBorder" +#define SC_UNO_PAGE_BOTTBORDER "BottomBorder" +#define SC_UNO_PAGE_TOPBORDER "TopBorder" +#define SC_UNO_PAGE_LEFTBRDDIST "LeftBorderDistance" +#define SC_UNO_PAGE_RIGHTBRDDIST "RightBorderDistance" +#define SC_UNO_PAGE_BOTTBRDDIST "BottomBorderDistance" +#define SC_UNO_PAGE_TOPBRDDIST "TopBorderDistance" +#define SC_UNO_PAGE_BORDERDIST "BorderDistance" +#define SC_UNO_PAGE_SHADOWFORM "ShadowFormat" +#define SC_UNO_PAGE_PAPERTRAY "PrinterPaperTray" +#define SC_UNO_PAGE_SCALEVAL "PageScale" +#define SC_UNO_PAGE_SCALETOPAG "ScaleToPages" +#define SC_UNO_PAGE_SCALETOX "ScaleToPagesX" +#define SC_UNO_PAGE_SCALETOY "ScaleToPagesY" +#define SC_UNO_PAGE_FIRSTPAGE "FirstPageNumber" +#define SC_UNO_PAGE_LEFTHDRCONT "LeftPageHeaderContent" +#define SC_UNO_PAGE_LEFTFTRCONT "LeftPageFooterContent" +#define SC_UNO_PAGE_RIGHTHDRCON "RightPageHeaderContent" +#define SC_UNO_PAGE_RIGHTFTRCON "RightPageFooterContent" +#define SC_UNO_PAGE_PRINTFORMUL "PrintFormulas" +#define SC_UNO_PAGE_PRINTZERO "PrintZeroValues" +#define SC_UNO_PAGE_HDRBACKCOL "HeaderBackColor" +#define SC_UNO_PAGE_HDRBACKTRAN "HeaderBackTransparent" +#define SC_UNO_PAGE_HDRGRFFILT "HeaderBackGraphicFilter" +#define SC_UNO_PAGE_HDRGRFLOC "HeaderBackGraphicLocation" +#define SC_UNO_PAGE_HDRGRFURL "HeaderBackGraphicURL" +#define SC_UNO_PAGE_HDRLEFTBOR "HeaderLeftBorder" +#define SC_UNO_PAGE_HDRRIGHTBOR "HeaderRightBorder" +#define SC_UNO_PAGE_HDRBOTTBOR "HeaderBottomBorder" +#define SC_UNO_PAGE_HDRTOPBOR "HeaderTopBorder" +#define SC_UNO_PAGE_HDRLEFTBDIS "HeaderLeftBorderDistance" +#define SC_UNO_PAGE_HDRRIGHTBDIS "HeaderRightBorderDistance" +#define SC_UNO_PAGE_HDRBOTTBDIS "HeaderBottomBorderDistance" +#define SC_UNO_PAGE_HDRTOPBDIS "HeaderTopBorderDistance" +#define SC_UNO_PAGE_HDRBRDDIST "HeaderBorderDistance" +#define SC_UNO_PAGE_HDRSHADOW "HeaderShadowFormat" +#define SC_UNO_PAGE_HDRLEFTMAR "HeaderLeftMargin" +#define SC_UNO_PAGE_HDRRIGHTMAR "HeaderRightMargin" +#define SC_UNO_PAGE_HDRBODYDIST "HeaderBodyDistance" +#define SC_UNO_PAGE_HDRHEIGHT "HeaderHeight" +#define SC_UNO_PAGE_HDRON "HeaderIsOn" +#define SC_UNO_PAGE_HDRDYNAMIC "HeaderIsDynamicHeight" +#define SC_UNO_PAGE_HDRSHARED "HeaderIsShared" +#define SC_UNO_PAGE_FTRBACKCOL "FooterBackColor" +#define SC_UNO_PAGE_FTRBACKTRAN "FooterBackTransparent" +#define SC_UNO_PAGE_FTRGRFFILT "FooterBackGraphicFilter" +#define SC_UNO_PAGE_FTRGRFLOC "FooterBackGraphicLocation" +#define SC_UNO_PAGE_FTRGRFURL "FooterBackGraphicURL" +#define SC_UNO_PAGE_FTRLEFTBOR "FooterLeftBorder" +#define SC_UNO_PAGE_FTRRIGHTBOR "FooterRightBorder" +#define SC_UNO_PAGE_FTRBOTTBOR "FooterBottomBorder" +#define SC_UNO_PAGE_FTRTOPBOR "FooterTopBorder" +#define SC_UNO_PAGE_FTRLEFTBDIS "FooterLeftBorderDistance" +#define SC_UNO_PAGE_FTRRIGHTBDIS "FooterRightBorderDistance" +#define SC_UNO_PAGE_FTRBOTTBDIS "FooterBottomBorderDistance" +#define SC_UNO_PAGE_FTRTOPBDIS "FooterTopBorderDistance" +#define SC_UNO_PAGE_FTRBRDDIST "FooterBorderDistance" +#define SC_UNO_PAGE_FTRSHADOW "FooterShadowFormat" +#define SC_UNO_PAGE_FTRLEFTMAR "FooterLeftMargin" +#define SC_UNO_PAGE_FTRRIGHTMAR "FooterRightMargin" +#define SC_UNO_PAGE_FTRBODYDIST "FooterBodyDistance" +#define SC_UNO_PAGE_FTRHEIGHT "FooterHeight" +#define SC_UNO_PAGE_FTRON "FooterIsOn" +#define SC_UNO_PAGE_FTRDYNAMIC "FooterIsDynamicHeight" +#define SC_UNO_PAGE_FTRSHARED "FooterIsShared" + +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; + using namespace rptui; +// ----------------------------------------------------------------------------- +// local functions +// ----------------------------------------------------------------------------- +void lcl_setModelReadOnly(const uno::Reference< embed::XStorage >& _xStorage,::boost::shared_ptr<rptui::OReportModel>& _rModel) +{ + uno::Reference<beans::XPropertySet> xProp(_xStorage,uno::UNO_QUERY); + sal_Int32 nOpenMode = embed::ElementModes::READ; + if ( xProp.is() ) + xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OpenMode"))) >>= nOpenMode; + + _rModel->SetReadOnly((nOpenMode & embed::ElementModes::WRITE) != embed::ElementModes::WRITE); +} +void lcl_stripLoadArguments( ::comphelper::MediaDescriptor& _rDescriptor, uno::Sequence< beans::PropertyValue >& _rArgs ) +{ + _rDescriptor.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) ) ); + _rDescriptor.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) ) ); + _rDescriptor.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ) ); + _rDescriptor >> _rArgs; +} +// ----------------------------------------------------------------------------- +void lcl_extractAndStartStatusIndicator( const ::comphelper::MediaDescriptor& _rDescriptor, uno::Reference< task::XStatusIndicator >& _rxStatusIndicator, + uno::Sequence< uno::Any >& _rCallArgs ) +{ + try + { + _rxStatusIndicator = _rDescriptor.getUnpackedValueOrDefault( _rDescriptor.PROP_STATUSINDICATOR(), _rxStatusIndicator ); + if ( _rxStatusIndicator.is() ) + { + _rxStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 ); + + sal_Int32 nLength = _rCallArgs.getLength(); + _rCallArgs.realloc( nLength + 1 ); + _rCallArgs[ nLength ] <<= _rxStatusIndicator; + } + } + catch( const uno::Exception& ) + { + OSL_ENSURE( sal_False, "lcl_extractAndStartStatusIndicator: caught an exception!" ); +// DBG_UNHANDLED_EXCEPTION(); + } +} +// ----------------------------------------------------------------------------- +typedef ::comphelper::OPropertyStateContainer OStyle_PBASE; +class OStyle; +typedef ::comphelper::OPropertyArrayUsageHelper < OStyle + > OStyle_PABASE; +typedef ::cppu::WeakImplHelper2< style::XStyle, beans::XMultiPropertyStates> TStyleBASE; + +class OStyle : public ::comphelper::OMutexAndBroadcastHelper + ,public TStyleBASE + ,public OStyle_PBASE + ,public OStyle_PABASE +{ + awt::Size m_aSize; + +protected: + void getPropertyDefaultByHandle( sal_Int32 _nHandle, uno::Any& _rDefault ) const; + ~OStyle(){} +public: + OStyle(); + + + DECLARE_XINTERFACE( ) + + // XPropertySet + com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException); + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + + // XStyle + ::sal_Bool SAL_CALL isUserDefined( ) throw (uno::RuntimeException); + ::sal_Bool SAL_CALL isInUse( ) throw (uno::RuntimeException); + ::rtl::OUString SAL_CALL getParentStyle( ) throw (uno::RuntimeException); + void SAL_CALL setParentStyle( const ::rtl::OUString& aParentStyle ) throw (container::NoSuchElementException, uno::RuntimeException); + // XNamed + ::rtl::OUString SAL_CALL getName( ) throw (uno::RuntimeException); + void SAL_CALL setName( const ::rtl::OUString& aName ) throw (uno::RuntimeException); + + // XMultiPropertyState + uno::Sequence< beans::PropertyState > SAL_CALL getPropertyStates( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException) + { + return OStyle_PBASE::getPropertyStates(aPropertyNames); + } + void SAL_CALL setAllPropertiesToDefault( ) throw (uno::RuntimeException); + void SAL_CALL setPropertiesToDefault( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException); + uno::Sequence< uno::Any > SAL_CALL getPropertyDefaults( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); +}; +// ----------------------------------------------------------------------------- +OStyle::OStyle() +:OStyle_PBASE(m_aBHelper) +,m_aSize(21000,29700) +{ + const ::Size aDefaultSize = SvxPaperInfo::GetDefaultPaperSize( MAP_100TH_MM ); + m_aSize.Height = aDefaultSize.Height(); + m_aSize.Width = aDefaultSize.Width(); + + const style::GraphicLocation eGraphicLocation = style::GraphicLocation_NONE; + const sal_Bool bFalse = sal_False; + const sal_Bool bTrue = sal_True; + const sal_Int32 nMargin = 2000; + //const sal_Int32 nColor = COL_WHITE; + const sal_Int32 nTransparent = COL_TRANSPARENT; + const sal_Int32 nZero = 0; + const sal_Int16 n16Zero = 0; + const sal_Int16 nNummeringType = style::NumberingType::ARABIC; + const ::rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("Default")); + const ::rtl::OUString sEmpty; + const table::BorderLine eBorderLine(0,0,0,0); + const table::ShadowFormat eShadowFormat(table::ShadowLocation_NONE,0,0,0); + const style::PageStyleLayout ePageStyleLayout = style::PageStyleLayout_ALL; + const sal_Int32 nBound = beans::PropertyAttribute::BOUND; + const sal_Int32 nMayBeVoid = beans::PropertyAttribute::MAYBEVOID; + + sal_Int32 i = 0; + registerPropertyNoMember( PROPERTY_NAME, ++i,nBound,::getCppuType( static_cast< ::rtl::OUString *>(NULL) ), &sName ); + + registerPropertyNoMember(PROPERTY_BACKCOLOR, ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nTransparent); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICFILT), ++i,nBound,::getCppuType((const ::rtl::OUString*)0) ,&sEmpty); + + registerPropertyNoMember(PROPERTY_BACKGRAPHICLOCATION, ++i,nBound,::getCppuType((const style::GraphicLocation*)0) ,&eGraphicLocation); + //registerPropertyNoMember(PROPERTY_BACKGRAPHICURL, ++i,nBound,::getCppuType((const ::rtl::OUString*)0) ,&sEmpty); + registerPropertyNoMember(PROPERTY_BACKTRANSPARENT, ++i,nBound,::getBooleanCppuType() ,&bTrue); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_BACKCOLOR), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_BORDERDIST), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_BOTTBORDER), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_BOTTBRDDIST), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(PROPERTY_BOTTOMMARGIN, ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nMargin); + registerPropertyNoMember(MAP_CHAR_LEN("DisplayName"), ++i,nBound,::getCppuType((rtl::OUString*)0) ,&sEmpty); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FIRSTPAGE), ++i,nBound,::getCppuType((const sal_Int16*)0) ,&n16Zero); + // + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKCOL), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nTransparent); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFFILT), ++i,nBound,::getCppuType((const ::rtl::OUString*)0) ,&sEmpty); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFLOC), ++i,nBound,::getCppuType((const style::GraphicLocation*)0) ,&eGraphicLocation); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFURL), ++i,nBound,::getCppuType((const ::rtl::OUString*)0) ,&sEmpty); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKTRAN), ++i,nBound,::getBooleanCppuType() ,&bTrue); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKCOL), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRBODYDIST), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRBRDDIST), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBOR), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBDIS), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_FTRDYNAMIC), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRHEIGHT), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRDYNAMIC), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRON), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHARED), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBOR), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBDIS), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTMAR), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_FTRON), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBOR), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBDIS),++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTMAR), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHADOW), ++i,nBound,::getCppuType((const table::ShadowFormat*)0) ,&eShadowFormat); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_FTRSHARED), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBOR), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBDIS), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + // + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKCOL), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nTransparent); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFFILT), ++i,nBound|nMayBeVoid,::getCppuType((const ::rtl::OUString*)0) ,&sEmpty); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFLOC), ++i,nBound|nMayBeVoid,::getCppuType((const style::GraphicLocation*)0) ,&eGraphicLocation); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFURL), ++i,nBound|nMayBeVoid,::getCppuType((const ::rtl::OUString*)0) ,&sEmpty); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKTRAN), ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bTrue); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKCOL), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRBODYDIST), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRBRDDIST), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBOR), ++i,nBound|nMayBeVoid,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBDIS), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_HDRDYNAMIC), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRHEIGHT), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRDYNAMIC), ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRON), ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHARED), ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBOR), ++i,nBound|nMayBeVoid,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBDIS), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTMAR), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_HDRON), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBOR), ++i,nBound|nMayBeVoid,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBDIS),++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTMAR), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHADOW), ++i,nBound|nMayBeVoid,::getCppuType((const table::ShadowFormat*)0) ,&eShadowFormat); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_HDRSHARED), ++i,nBound,::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBOR), ++i,nBound|nMayBeVoid,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBDIS), ++i,nBound|nMayBeVoid,::getCppuType((const sal_Int32*)0) ,&nZero); + // + registerProperty(PROPERTY_HEIGHT, ++i,nBound,&m_aSize.Height, ::getCppuType((const sal_Int32*)0) ); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_BACKTRANS), ++i,nBound, ::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(PROPERTY_ISLANDSCAPE, ++i,nBound, ::getBooleanCppuType() ,&bFalse); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_LEFTBORDER), ++i,nBound, ::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_LEFTBRDDIST), ++i,nBound, ::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(PROPERTY_LEFTMARGIN, ++i,beans::PropertyAttribute::BOUND, ::getCppuType((const sal_Int32*)0) ,&nMargin); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_LEFTFTRCONT), ++i,nBound,::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0) ,NULL); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_LEFTHDRCONT), ++i,nBound,::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0) ,NULL); + registerPropertyNoMember(PROPERTY_NUMBERINGTYPE, ++i,nBound,::getCppuType((const sal_Int16*)0) ,&nNummeringType); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_SCALEVAL), ++i,nBound,::getCppuType((const sal_Int16*)0) ,&n16Zero); + registerPropertyNoMember(PROPERTY_PAGESTYLELAYOUT, ++i,nBound,::getCppuType((const style::PageStyleLayout*)0) ,&ePageStyleLayout); + const ::rtl::OUString sPaperTray(RTL_CONSTASCII_USTRINGPARAM("[From printer settings]")); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_PAPERTRAY), ++i,nBound,::getCppuType((const ::rtl::OUString*)0) ,&sPaperTray); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTBORDER), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTBRDDIST),++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(PROPERTY_RIGHTMARGIN, ++i,beans::PropertyAttribute::BOUND,::getCppuType((const sal_Int32*)0) ,&nMargin); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTFTRCON), ++i,nBound,::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0) ,NULL); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTHDRCON), ++i,nBound,::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0) ,NULL); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOPAG), ++i,nBound,::getCppuType((const sal_Int16*)0) ,&n16Zero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOX), ++i,nBound,::getCppuType((const sal_Int16*)0) ,&n16Zero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOY), ++i,nBound,::getCppuType((const sal_Int16*)0) ,&n16Zero); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_SHADOWFORM), ++i,nBound,::getCppuType((const table::ShadowFormat*)0) ,&eShadowFormat); + registerProperty(PROPERTY_PAPERSIZE, ++i,beans::PropertyAttribute::BOUND,&m_aSize,::getCppuType((const awt::Size*)0) ); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_TOPBORDER), ++i,nBound,::getCppuType((const table::BorderLine*)0) ,&eBorderLine); + registerPropertyNoMember(MAP_CHAR_LEN(SC_UNO_PAGE_TOPBRDDIST), ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nZero); + registerPropertyNoMember(PROPERTY_TOPMARGIN, ++i,nBound,::getCppuType((const sal_Int32*)0) ,&nMargin); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKTRAN),++i,nBound,::getBooleanCppuType() ,&bFalse); + //registerPropertyNoMember(MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKTRAN),++i,nBound,::getBooleanCppuType() ,&bFalse); + uno::Reference< container::XNameContainer> xAttribs = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast< xml::AttributeData* >(NULL))); + registerPropertyNoMember(MAP_CHAR_LEN("UserDefinedAttributes"), ++i,nBound,::getCppuType((uno::Reference<container::XNameContainer>*)0) ,&xAttribs); + registerProperty(PROPERTY_WIDTH, ++i,nBound,&m_aSize.Width,::getCppuType((const sal_Int32*)0) ); + //registerPropertyNoMember(MAP_CHAR_LEN(SC_UNONAME_WRITING), ++i,nBound,:.getCppuType((sal_Int16*)0) ,&n16Zero); + registerPropertyNoMember(MAP_CHAR_LEN("PrinterName"), ++i,nBound,::getCppuType((const ::rtl::OUString*)0),&sEmpty); + uno::Sequence<sal_Int8> aSe; + registerPropertyNoMember(MAP_CHAR_LEN("PrinterSetup"), ++i,nBound,::getCppuType((const uno::Sequence<sal_Int8>*)0),&aSe); + + +} +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2(OStyle,TStyleBASE,OStyle_PBASE) +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo> SAL_CALL OStyle::getPropertySetInfo() throw(uno::RuntimeException) +{ + return createPropertySetInfo( getInfoHelper() ); +} +// ----------------------------------------------------------------------------- +void OStyle::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, uno::Any& /*_rDefault*/ ) const +{ +} +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& OStyle::getInfoHelper() +{ + return *const_cast<OStyle*>(this)->getArrayHelper(); +} +//-------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OStyle::createArrayHelper( ) const +{ + uno::Sequence< beans::Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ----------------------------------------------------------------------------- +// XStyle +::sal_Bool SAL_CALL OStyle::isUserDefined( ) throw (uno::RuntimeException) +{ + return sal_False; +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OStyle::isInUse( ) throw (uno::RuntimeException) +{ + return sal_True; +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OStyle::getParentStyle( ) throw (uno::RuntimeException) +{ + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStyle::setParentStyle( const ::rtl::OUString& /*aParentStyle*/ ) throw (container::NoSuchElementException, uno::RuntimeException) +{ +} +// ----------------------------------------------------------------------------- +// XNamed +::rtl::OUString SAL_CALL OStyle::getName( ) throw (uno::RuntimeException) +{ + ::rtl::OUString sName; + getPropertyValue(PROPERTY_NAME) >>= sName; + return sName; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStyle::setName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) +{ + setPropertyValue(PROPERTY_NAME,uno::makeAny(aName)); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStyle::setAllPropertiesToDefault( ) throw (uno::RuntimeException) +{ +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStyle::setPropertiesToDefault( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + const ::rtl::OUString* pIter = aPropertyNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aPropertyNames.getLength(); + for(;pIter != pEnd;++pIter) + setPropertyToDefault(*pIter); +} +// ----------------------------------------------------------------------------- +uno::Sequence< uno::Any > SAL_CALL OStyle::getPropertyDefaults( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Sequence< uno::Any > aRet(aPropertyNames.getLength()); + const ::rtl::OUString* pIter = aPropertyNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aPropertyNames.getLength(); + for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i) + aRet[i] = getPropertyDefault(*pIter); + return aRet; +} +namespace +{ + class FactoryLoader : public ::osl::Thread + { + ::rtl::OUString m_sMimeType; + uno::Reference< uno::XComponentContext > m_xContext; + public: + FactoryLoader(const ::rtl::OUString& _sMimeType,uno::Reference< uno::XComponentContext > const & _xContext) + :m_sMimeType(_sMimeType) + ,m_xContext(_xContext) + {} + + protected: + virtual ~FactoryLoader(){} + + /// Working method which should be overridden. + virtual void SAL_CALL run(); + virtual void SAL_CALL onTerminated(); + }; + + void SAL_CALL FactoryLoader::run() + { + try + { + uno::Reference<frame::XComponentLoader> xFrameLoad( m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) + ,m_xContext) + ,uno::UNO_QUERY); + ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank")); + sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE; + uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY)->findFrame(sTarget,nFrameSearchFlag); + xFrameLoad.set( xFrame,uno::UNO_QUERY); + + if ( xFrameLoad.is() ) + { + uno::Sequence < beans::PropertyValue > aArgs( 3); + sal_Int32 nLen = 0; + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate")); + aArgs[nLen++].Value <<= sal_False; + + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")); + aArgs[nLen++].Value <<= sal_True; + + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden")); + aArgs[nLen++].Value <<= sal_True; + + uno::Reference< lang::XMultiServiceFactory > xFac(m_xContext->getServiceManager(),uno::UNO_QUERY); + ::comphelper::MimeConfigurationHelper aHelper(xFac); + SvtModuleOptions aModuleOptions; + uno::Reference< frame::XModel > xModel(xFrameLoad->loadComponentFromURL( + aModuleOptions.GetFactoryEmptyDocumentURL( aModuleOptions.ClassifyFactoryByServiceName( aHelper.GetDocServiceNameFromMediaType(m_sMimeType) )), + ::rtl::OUString(), // empty frame name + 0, + aArgs + ),uno::UNO_QUERY); + ::comphelper::disposeComponent(xModel); + } + } + catch(uno::Exception& ex) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + void SAL_CALL FactoryLoader::onTerminated() + { + delete this; + } +} +// ----------------------------------------------------------------------------- +struct OReportDefinitionImpl +{ + uno::WeakReference< uno::XInterface > m_xParent; + ::cppu::OInterfaceContainerHelper m_aStorageChangeListeners; + ::cppu::OInterfaceContainerHelper m_aCloseListener; + ::cppu::OInterfaceContainerHelper m_aModifyListeners; + ::cppu::OInterfaceContainerHelper m_aDocEventListeners; + ::std::vector< uno::Reference< frame::XController> > m_aControllers; + uno::Sequence< beans::PropertyValue > m_aArgs; + + uno::Reference< report::XGroups > m_xGroups; + uno::Reference< report::XSection> m_xReportHeader; + uno::Reference< report::XSection> m_xReportFooter; + uno::Reference< report::XSection> m_xPageHeader; + uno::Reference< report::XSection> m_xPageFooter; + uno::Reference< report::XSection> m_xDetail; + uno::Reference< embed::XStorage > m_xStorage; + uno::Reference< frame::XController > m_xCurrentController; + uno::Reference< container::XIndexAccess > m_xViewData; + uno::Reference< container::XNameAccess > m_xStyles; + uno::Reference< container::XNameAccess> m_xXMLNamespaceMap; + uno::Reference< container::XNameAccess> m_xGradientTable; + uno::Reference< container::XNameAccess> m_xHatchTable; + uno::Reference< container::XNameAccess> m_xBitmapTable; + uno::Reference< container::XNameAccess> m_xTransparencyGradientTable; + uno::Reference< container::XNameAccess> m_xDashTable; + uno::Reference< container::XNameAccess> m_xMarkerTable; + uno::Reference< report::XFunctions > m_xFunctions; + uno::Reference< ui::XUIConfigurationManager> m_xUIConfigurationManager; + uno::Reference< util::XNumberFormatsSupplier> m_xNumberFormatsSupplier; + uno::Reference< sdbc::XConnection> m_xActiveConnection; + uno::Reference< frame::XTitle > m_xTitleHelper; + uno::Reference< frame::XUntitledNumbers > m_xNumberedControllers; + uno::Reference< document::XDocumentProperties > m_xDocumentProperties; + + ::boost::shared_ptr< ::comphelper::EmbeddedObjectContainer> + m_pObjectContainer; + ::boost::shared_ptr<rptui::OReportModel> m_pReportModel; + ::rtl::OUString m_sCaption; + ::rtl::OUString m_sCommand; + ::rtl::OUString m_sFilter; + ::rtl::OUString m_sMimeType; + ::rtl::OUString m_sIdentifier; + ::rtl::OUString m_sDataSourceName; + awt::Size m_aVisualAreaSize; + ::sal_Int64 m_nAspect; + ::sal_Int16 m_nGroupKeepTogether; + ::sal_Int16 m_nPageHeaderOption; + ::sal_Int16 m_nPageFooterOption; + ::sal_Int32 m_nCommandType; + sal_Bool m_bControllersLocked; + sal_Bool m_bModified; + sal_Bool m_bEscapeProcessing; + sal_Bool m_bSetModifiedEnabled; + OReportDefinitionImpl(::osl::Mutex& _aMutex) + :m_aStorageChangeListeners(_aMutex) + ,m_aCloseListener(_aMutex) + ,m_aModifyListeners(_aMutex) + ,m_aDocEventListeners(_aMutex) + ,m_sMimeType(MIMETYPE_OASIS_OPENDOCUMENT_TEXT) + ,m_sIdentifier(SERVICE_REPORTDEFINITION) + // default visual area is 8 x 7 cm + ,m_aVisualAreaSize( 8000, 7000 ) + ,m_nAspect(embed::Aspects::MSOLE_CONTENT) + ,m_nGroupKeepTogether(0) + ,m_nPageHeaderOption(0) + ,m_nPageFooterOption(0) + ,m_nCommandType(sdb::CommandType::TABLE) + ,m_bControllersLocked(sal_False) + ,m_bModified(sal_False) + ,m_bEscapeProcessing(sal_True) + ,m_bSetModifiedEnabled( sal_True ) + {} + + OReportDefinitionImpl(::osl::Mutex& _aMutex,const OReportDefinitionImpl& _aCopy) + :m_aStorageChangeListeners(_aMutex) + ,m_aCloseListener(_aMutex) + ,m_aModifyListeners(_aMutex) + ,m_aDocEventListeners(_aMutex) + ,m_sMimeType(_aCopy.m_sMimeType) + ,m_sIdentifier(_aCopy.m_sIdentifier) + ,m_nGroupKeepTogether(_aCopy.m_nGroupKeepTogether) + ,m_nPageHeaderOption(_aCopy.m_nPageHeaderOption) + ,m_nPageFooterOption(_aCopy.m_nPageFooterOption) + ,m_nCommandType(_aCopy.m_nCommandType) + ,m_bControllersLocked(_aCopy.m_bControllersLocked) + ,m_bModified(_aCopy.m_bModified) + ,m_bEscapeProcessing(_aCopy.m_bEscapeProcessing) + {} + ~OReportDefinitionImpl(); +}; +OReportDefinitionImpl::~OReportDefinitionImpl() +{ +} + +DBG_NAME( rpt_OReportDefinition ) +// ----------------------------------------------------------------------------- +OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > const & _xContext) +: ReportDefinitionBase(m_aMutex) +,ReportDefinitionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,m_aProps(new OReportComponentProperties(_xContext)) +,m_pImpl(new OReportDefinitionImpl(m_aMutex)) +{ + DBG_CTOR( rpt_OReportDefinition,NULL); + m_aProps->m_sName = RPT_RESSTRING(RID_STR_REPORT,m_aProps->m_xContext->getServiceManager()); + osl_incrementInterlockedCount(&m_refCount); + { + init(); + m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext); + m_pImpl->m_xDetail = new OSection(this,m_aProps->m_xContext); + m_pImpl->m_xDetail->setName(RPT_RESSTRING(RID_STR_DETAIL,m_aProps->m_xContext->getServiceManager())); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > const & _xContext + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,uno::Reference< drawing::XShape >& _xShape) +: ReportDefinitionBase(m_aMutex) +,ReportDefinitionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,m_aProps(new OReportComponentProperties(_xContext)) +,m_pImpl(new OReportDefinitionImpl(m_aMutex)) +{ + m_aProps->m_sName = RPT_RESSTRING(RID_STR_REPORT,m_aProps->m_xContext->getServiceManager()); + m_aProps->m_xFactory = _xFactory; + osl_incrementInterlockedCount(&m_refCount); + { + m_aProps->setShape(_xShape,this,m_refCount); + init(); + m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext); + m_pImpl->m_xDetail = new OSection(this,m_aProps->m_xContext); + m_pImpl->m_xDetail->setName(RPT_RESSTRING(RID_STR_DETAIL,m_aProps->m_xContext->getServiceManager())); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OReportDefinition::OReportDefinition(const OReportDefinition& _rCopy) +: cppu::BaseMutex() +,ReportDefinitionBase(m_aMutex) +,ReportDefinitionPropertySet(_rCopy.m_aProps->m_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,comphelper::IEmbeddedHelper() +,m_aProps(new OReportComponentProperties(*_rCopy.m_aProps)) +,m_pImpl(new OReportDefinitionImpl(m_aMutex,*_rCopy.m_pImpl)) +{ + DBG_CTOR( rpt_OReportDefinition,NULL); + osl_incrementInterlockedCount(&m_refCount); + { + init(); + OGroups* pGroups = new OGroups(this,m_aProps->m_xContext); + m_pImpl->m_xGroups = pGroups; + pGroups->copyGroups(_rCopy.m_pImpl->m_xGroups); + m_pImpl->m_xDetail = new OSection(this,m_aProps->m_xContext); + OSection::lcl_copySection(_rCopy.m_pImpl->m_xDetail,m_pImpl->m_xDetail); + + setPageHeaderOn(_rCopy.m_pImpl->m_xPageHeader.is()); + setPageFooterOn(_rCopy.m_pImpl->m_xPageFooter.is()); + setReportHeaderOn(_rCopy.m_pImpl->m_xReportHeader.is()); + setReportFooterOn(_rCopy.m_pImpl->m_xReportFooter.is()); + OSection::lcl_copySection(_rCopy.m_pImpl->m_xPageHeader,m_pImpl->m_xPageHeader); + OSection::lcl_copySection(_rCopy.m_pImpl->m_xPageFooter,m_pImpl->m_xPageFooter); + OSection::lcl_copySection(_rCopy.m_pImpl->m_xReportHeader,m_pImpl->m_xReportHeader); + OSection::lcl_copySection(_rCopy.m_pImpl->m_xReportFooter,m_pImpl->m_xReportFooter); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OReportDefinition::~OReportDefinition() +{ + DBG_DTOR( rpt_OReportDefinition,NULL); + if ( !ReportDefinitionBase::rBHelper.bInDispose && !ReportDefinitionBase::rBHelper.bDisposed ) + { + acquire(); + dispose(); + } +} +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition, ReportDefinitionBase ) +//IMPLEMENT_FORWARD_XINTERFACE2(OReportDefinition,ReportDefinitionBase,ReportDefinitionPropertySet) +void OReportDefinition::init() +{ + try + { + static bool s_bFirstTime = sal_True; + if ( s_bFirstTime ) + { + s_bFirstTime = false; + const uno::Sequence< ::rtl::OUString > aMimeTypes = getAvailableMimeTypes(); + const ::rtl::OUString* pIter = aMimeTypes.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aMimeTypes.getLength(); + for ( ; pIter != pEnd; ++pIter ) + { + FactoryLoader* pCreatorThread = new FactoryLoader(*pIter,m_aProps->m_xContext); + pCreatorThread->createSuspended(); + pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal); + pCreatorThread->resume(); + } // for ( ; pIter != pEnd; ++pIter ) + } + + m_pImpl->m_pReportModel.reset(new OReportModel(this)); + m_pImpl->m_pReportModel->GetItemPool().FreezeIdRanges(); + m_pImpl->m_pReportModel->SetScaleUnit( MAP_100TH_MM ); + SdrLayerAdmin& rAdmin = m_pImpl->m_pReportModel->GetLayerAdmin(); + rAdmin.NewStandardLayer(RPT_LAYER_FRONT); + rAdmin.NewLayer(UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "back" ) ), RPT_LAYER_BACK ); + rAdmin.NewLayer( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "HiddenLayer" ) ), RPT_LAYER_HIDDEN ); + + m_pImpl->m_xFunctions = new OFunctions(this,m_aProps->m_xContext); + if ( !m_pImpl->m_xStorage.is() ) + m_pImpl->m_xStorage = ::comphelper::OStorageHelper::GetTemporaryStorage(); + + uno::Reference<beans::XPropertySet> xStorProps(m_pImpl->m_xStorage,uno::UNO_QUERY); + if ( xStorProps.is()) + { + ::rtl::OUString sMediaType; + xStorProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType"))) >>= sMediaType; + if ( !sMediaType.getLength() ) + xStorProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")),uno::makeAny(MIMETYPE_OASIS_OPENDOCUMENT_REPORT)); + } + m_pImpl->m_pObjectContainer.reset( new comphelper::EmbeddedObjectContainer(m_pImpl->m_xStorage , static_cast<cppu::OWeakObject*>(this) ) ); + } + catch(uno::Exception) + { + OSL_ENSURE(0,"Error!"); + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::dispose() throw(uno::RuntimeException) +{ + ReportDefinitionPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::disposing() +{ + notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnUnload"))); + + uno::Reference< frame::XModel > xHoldAlive( this ); + + lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) ); + m_pImpl->m_aModifyListeners.disposeAndClear( aDisposeEvent ); + m_pImpl->m_aCloseListener.disposeAndClear( aDisposeEvent ); + m_pImpl->m_aDocEventListeners.disposeAndClear( aDisposeEvent ); + m_pImpl->m_aStorageChangeListeners.disposeAndClear( aDisposeEvent ); + + // SYNCHRONIZED ---> + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::ResettableMutexGuard aGuard(m_aMutex); + + m_pImpl->m_aControllers.clear(); + + ::comphelper::disposeComponent(m_pImpl->m_xGroups); + m_pImpl->m_xReportHeader.clear(); + m_pImpl->m_xReportFooter.clear(); + m_pImpl->m_xPageHeader.clear(); + m_pImpl->m_xPageFooter.clear(); + m_pImpl->m_xDetail.clear(); + //::comphelper::disposeComponent(m_pImpl->m_xReportHeader); + //::comphelper::disposeComponent(m_pImpl->m_xReportFooter); + //::comphelper::disposeComponent(m_pImpl->m_xPageHeader); + //::comphelper::disposeComponent(m_pImpl->m_xPageFooter); + //::comphelper::disposeComponent(m_pImpl->m_xDetail); + ::comphelper::disposeComponent(m_pImpl->m_xFunctions); + + //::comphelper::disposeComponent(m_pImpl->m_xStorage); + // don't dispose, this currently is the task of either the ref count going to + // 0, or of the embedded object (if we're embedded, which is the only possible + // case so far) + // #i78366# / 2007-06-18 / frank.schoenheit@sun.com + m_pImpl->m_xStorage.clear(); + m_pImpl->m_xViewData.clear(); + m_pImpl->m_xCurrentController.clear(); + m_pImpl->m_xNumberFormatsSupplier.clear(); + m_pImpl->m_xStyles.clear(); + m_pImpl->m_xXMLNamespaceMap.clear(); + m_pImpl->m_xGradientTable.clear(); + m_pImpl->m_xHatchTable.clear(); + m_pImpl->m_xBitmapTable.clear(); + m_pImpl->m_xTransparencyGradientTable.clear(); + m_pImpl->m_xDashTable.clear(); + m_pImpl->m_xMarkerTable.clear(); + m_pImpl->m_xUIConfigurationManager.clear(); + m_pImpl->m_pReportModel.reset(); + m_pImpl->m_pObjectContainer.reset(); + m_pImpl->m_aArgs.realloc(0); + m_pImpl->m_xTitleHelper.clear(); + m_pImpl->m_xNumberedControllers.clear(); + // <--- SYNCHRONIZED +} + +// ----------------------------------------------------------------------------- +::rtl::OUString OReportDefinition::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OReportDefinition")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportDefinition::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OReportDefinition::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_REPORTDEFINITION; + + return aServices; +} +// -------------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + // first collect the services which are supported by our aggregate + uno::Sequence< ::rtl::OUString > aSupported; + if ( m_aProps->m_xServiceInfo.is() ) + aSupported = m_aProps->m_xServiceInfo->getSupportedServiceNames(); + + // append our own service, if necessary + if ( 0 == ::comphelper::findValue( aSupported, SERVICE_REPORTDEFINITION, sal_True ).getLength() ) + { + sal_Int32 nLen = aSupported.getLength(); + aSupported.realloc( nLen + 1 ); + aSupported[ nLen ] = SERVICE_REPORTDEFINITION; + } + + // outta here + return aSupported; +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OReportDefinition::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException) +{ + return ::comphelper::findValue( getSupportedServiceNames(), _rServiceName, sal_True ).getLength() != 0; +} + +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OReportDefinition::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = ReportDefinitionBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = ReportDefinitionPropertySet::queryInterface(_rType); + + return aReturn.hasValue() ? aReturn : (m_aProps->m_xProxy.is() ? m_aProps->m_xProxy->queryAggregation(_rType) : aReturn); +} +// -------------------------------------------------------------------------------- +uno::Sequence< uno::Type > SAL_CALL OReportDefinition::getTypes( ) throw (uno::RuntimeException) +{ + if ( m_aProps->m_xTypeProvider.is() ) + return ::comphelper::concatSequences( + ReportDefinitionBase::getTypes(), + m_aProps->m_xTypeProvider->getTypes() + ); + return ReportDefinitionBase::getTypes(); +} +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OReportDefinition::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OReportDefinition(xContext)); +} + +// ----------------------------------------------------------------------------- +// XReportDefinition +::rtl::OUString SAL_CALL OReportDefinition::getCaption() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_sCaption; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException) +{ + set(PROPERTY_CAPTION,_caption,m_pImpl->m_sCaption); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OReportDefinition::getGroupKeepTogether() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_nGroupKeepTogether; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setGroupKeepTogether( ::sal_Int16 _groupkeeptogether ) throw (uno::RuntimeException) +{ + if ( _groupkeeptogether < report::GroupKeepTogether::PER_PAGE || _groupkeeptogether > report::GroupKeepTogether::PER_COLUMN ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::GroupKeepTogether")) + ,*this + ,1 + ,m_aProps->m_xContext); + set(PROPERTY_GROUPKEEPTOGETHER,_groupkeeptogether,m_pImpl->m_nGroupKeepTogether); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OReportDefinition::getPageHeaderOption() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_nPageHeaderOption; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setPageHeaderOption( ::sal_Int16 _pageheaderoption ) throw (uno::RuntimeException) +{ + if ( _pageheaderoption < report::ReportPrintOption::ALL_PAGES || _pageheaderoption > report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ReportPrintOption")) + ,*this + ,1 + ,m_aProps->m_xContext); + set(PROPERTY_PAGEHEADEROPTION,_pageheaderoption,m_pImpl->m_nPageHeaderOption); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OReportDefinition::getPageFooterOption() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_nPageFooterOption; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setPageFooterOption( ::sal_Int16 _pagefooteroption ) throw (uno::RuntimeException) +{ + if ( _pagefooteroption < report::ReportPrintOption::ALL_PAGES || _pagefooteroption > report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ReportPrintOption")) + ,*this + ,1 + ,m_aProps->m_xContext); + set(PROPERTY_PAGEFOOTEROPTION,_pagefooteroption,m_pImpl->m_nPageFooterOption); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportDefinition::getCommand() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_sCommand; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setCommand( const ::rtl::OUString& _command ) throw (uno::RuntimeException) +{ + set(PROPERTY_COMMAND,_command,m_pImpl->m_sCommand); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OReportDefinition::getCommandType() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_nCommandType; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setCommandType( ::sal_Int32 _commandtype ) throw (uno::RuntimeException) +{ + if ( _commandtype < sdb::CommandType::TABLE || _commandtype > sdb::CommandType::COMMAND ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::sdb::CommandType")) + ,*this + ,1 + ,m_aProps->m_xContext); + set(PROPERTY_COMMANDTYPE,_commandtype,m_pImpl->m_nCommandType); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportDefinition::getFilter() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_sFilter; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setFilter( const ::rtl::OUString& _filter ) throw (uno::RuntimeException) +{ + set(PROPERTY_FILTER,_filter,m_pImpl->m_sFilter); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::getEscapeProcessing() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_bEscapeProcessing; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setEscapeProcessing( ::sal_Bool _escapeprocessing ) throw (uno::RuntimeException) +{ + set(PROPERTY_ESCAPEPROCESSING,_escapeprocessing,m_pImpl->m_bEscapeProcessing); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::getReportHeaderOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xReportHeader.is(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setReportHeaderOn( ::sal_Bool _reportheaderon ) throw (uno::RuntimeException) +{ + if ( _reportheaderon != m_pImpl->m_xReportHeader.is() ) + { + setSection(PROPERTY_REPORTHEADERON,_reportheaderon,RPT_RESSTRING(RID_STR_REPORT_HEADER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xReportHeader); + } +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::getReportFooterOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xReportFooter.is(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setReportFooterOn( ::sal_Bool _reportfooteron ) throw (uno::RuntimeException) +{ + if ( _reportfooteron != m_pImpl->m_xReportFooter.is() ) + { + setSection(PROPERTY_REPORTFOOTERON,_reportfooteron,RPT_RESSTRING(RID_STR_REPORT_FOOTER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xReportFooter); + } +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::getPageHeaderOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xPageHeader.is(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setPageHeaderOn( ::sal_Bool _pageheaderon ) throw (uno::RuntimeException) +{ + if ( _pageheaderon != m_pImpl->m_xPageHeader.is() ) + { + setSection(PROPERTY_PAGEHEADERON,_pageheaderon,RPT_RESSTRING(RID_STR_PAGE_HEADER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xPageHeader); + } +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::getPageFooterOn() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xPageFooter.is(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setPageFooterOn( ::sal_Bool _pagefooteron ) throw (uno::RuntimeException) +{ + if ( _pagefooteron != m_pImpl->m_xPageFooter.is() ) + { + setSection(PROPERTY_PAGEFOOTERON,_pagefooteron,RPT_RESSTRING(RID_STR_PAGE_FOOTER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xPageFooter); + } +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XGroups > SAL_CALL OReportDefinition::getGroups() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xGroups; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OReportDefinition::getReportHeader() throw (container::NoSuchElementException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_pImpl->m_xReportHeader.is() ) + throw container::NoSuchElementException(); + return m_pImpl->m_xReportHeader; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OReportDefinition::getPageHeader() throw (container::NoSuchElementException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_pImpl->m_xPageHeader.is() ) + throw container::NoSuchElementException(); + return m_pImpl->m_xPageHeader; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OReportDefinition::getDetail() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xDetail; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OReportDefinition::getPageFooter() throw (container::NoSuchElementException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_pImpl->m_xPageFooter.is() ) + throw container::NoSuchElementException(); + return m_pImpl->m_xPageFooter; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > SAL_CALL OReportDefinition::getReportFooter() throw (container::NoSuchElementException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_pImpl->m_xReportFooter.is() ) + throw container::NoSuchElementException(); + return m_pImpl->m_xReportFooter; +} +//------------------------------------------------------------------------------ +uno::Reference< document::XEventBroadcaster > SAL_CALL OReportDefinition::getEventBroadcaster( ) throw (lang::DisposedException, uno::Exception, uno::RuntimeException) +{ + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return this; +} +//------------------------------------------------------------------------------ +// XReportComponent +REPORTCOMPONENT_MASTERDETAIL(OReportDefinition,*m_aProps) +REPORTCOMPONENT_IMPL(OReportDefinition,*m_aProps) +REPORTCOMPONENT_IMPL2(OReportDefinition,*m_aProps) + +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OReportDefinition::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return ReportDefinitionPropertySet::getPropertySetInfo(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportDefinitionPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OReportDefinition::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return ReportDefinitionPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportDefinitionPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportDefinitionPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportDefinitionPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportDefinitionPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::getParent( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + uno::Reference< container::XChild > xChild; + comphelper::query_aggregation(m_aProps->m_xProxy,xChild); + if ( xChild.is() ) + return xChild->getParent(); + return m_pImpl->m_xParent; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps->m_xParent = uno::Reference< container::XChild >(Parent,uno::UNO_QUERY); + m_pImpl->m_xParent = Parent; + uno::Reference< container::XChild > xChild; + comphelper::query_aggregation(m_aProps->m_xProxy,xChild); + if ( xChild.is() ) + xChild->setParent(Parent); +} +// ----------------------------------------------------------------------------- +// XCloneable +uno::Reference< util::XCloneable > SAL_CALL OReportDefinition::createClone( ) throw (uno::RuntimeException) +{ + OSL_ENSURE(0,"Not yet implemented correctly"); + uno::Reference< report::XReportComponent> xSource = this; + uno::Reference< report::XReportDefinition> xSet(cloneObject(xSource,m_aProps->m_xFactory,SERVICE_REPORTDEFINITION),uno::UNO_QUERY_THROW); + return xSet.get(); +} +// ----------------------------------------------------------------------------- +void OReportDefinition::setSection( const ::rtl::OUString& _sProperty + ,const sal_Bool& _bOn + ,const ::rtl::OUString& _sName + ,uno::Reference< report::XSection>& _member) +{ + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l); + lcl_createSectionIfNeeded(_bOn ,this,_member,_sProperty == PROPERTY_PAGEHEADERON || _sProperty == PROPERTY_PAGEFOOTERON); + if ( _member.is() ) + _member->setName(_sName); + } + l.notify(); +} +// ----------------------------------------------------------------------------- +// XCloseBroadcaster +void SAL_CALL OReportDefinition::addCloseListener( const uno::Reference< util::XCloseListener >& _xListener ) throw (uno::RuntimeException) +{ + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( _xListener.is() ) + m_pImpl->m_aCloseListener.addInterface(_xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::removeCloseListener( const uno::Reference< util::XCloseListener >& _xListener ) throw (uno::RuntimeException) +{ + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_aCloseListener.removeInterface(_xListener); +} +// ----------------------------------------------------------------------------- +// XCloseable +void SAL_CALL OReportDefinition::close( ::sal_Bool _bDeliverOwnership ) throw (util::CloseVetoException, uno::RuntimeException) +{ + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::ResettableMutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + // notify our container listeners + lang::EventObject aEvt( static_cast< ::cppu::OWeakObject* >( this ) ); + aGuard.clear(); + m_pImpl->m_aCloseListener.forEach<util::XCloseListener>( + ::boost::bind(&util::XCloseListener::queryClosing,_1,boost::cref(aEvt),boost::cref(_bDeliverOwnership))); + aGuard.reset(); + + + ::std::vector< uno::Reference< frame::XController> > aCopy = m_pImpl->m_aControllers; + ::std::vector< uno::Reference< frame::XController> >::iterator aIter = aCopy.begin(); + ::std::vector< uno::Reference< frame::XController> >::iterator aEnd = aCopy.end(); + for (;aIter != aEnd ; ++aIter) + { + if ( aIter->is() ) + { + try + { + uno::Reference< util::XCloseable> xFrame( (*aIter)->getFrame(), uno::UNO_QUERY ); + if ( xFrame.is() ) + xFrame->close( _bDeliverOwnership ); + } + catch( const util::CloseVetoException& ) { throw; } + catch( const uno::Exception& ) + { + OSL_ENSURE( sal_False, "ODatabaseDocument::impl_closeControllerFrames: caught an unexpected exception!" ); + } + } + } + + aGuard.clear(); + m_pImpl->m_aCloseListener.notifyEach(&util::XCloseListener::notifyClosing,aEvt); + aGuard.reset(); + + dispose(); +} +// ----------------------------------------------------------------------------- +// XModel +::sal_Bool SAL_CALL OReportDefinition::attachResource( const ::rtl::OUString& /*_rURL*/, const uno::Sequence< beans::PropertyValue >& _aArguments ) throw (uno::RuntimeException) +{ + // LLA: we had a deadlock problem in our context, so we get the SolarMutex earlier. + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + ::comphelper::MediaDescriptor aDescriptor( _aArguments ); + fillArgs(aDescriptor); + m_pImpl->m_pReportModel->SetModified(sal_False); + return sal_True; +} +// ----------------------------------------------------------------------------- +void OReportDefinition::fillArgs(::comphelper::MediaDescriptor& _aDescriptor) +{ + uno::Sequence<beans::PropertyValue> aComponentData; + aComponentData = _aDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ComponentData")),aComponentData); + if ( aComponentData.getLength() && (!m_pImpl->m_xActiveConnection.is() || !m_pImpl->m_xNumberFormatsSupplier.is()) ) + { + ::comphelper::SequenceAsHashMap aComponentDataMap( aComponentData ); + m_pImpl->m_xActiveConnection = aComponentDataMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")),m_pImpl->m_xActiveConnection); + m_pImpl->m_xNumberFormatsSupplier = dbtools::getNumberFormats(m_pImpl->m_xActiveConnection); + } + if ( !m_pImpl->m_xNumberFormatsSupplier.is() ) + { + m_pImpl->m_xNumberFormatsSupplier.set( + m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatsSupplier")) ,m_aProps->m_xContext), + uno::UNO_QUERY_THROW + ); + } + lcl_stripLoadArguments( _aDescriptor, m_pImpl->m_aArgs ); + ::rtl::OUString sCaption; + sCaption = _aDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle")),sCaption); + setCaption(sCaption); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportDefinition::getURL( ) throw (uno::RuntimeException) +{ + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +uno::Sequence< beans::PropertyValue > SAL_CALL OReportDefinition::getArgs( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_aArgs; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::connectController( const uno::Reference< frame::XController >& _xController ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_aControllers.push_back(_xController); + sal_Int32 nCount; + if ( _xController.is() && m_pImpl->m_xViewData.is() && ( nCount = m_pImpl->m_xViewData->getCount()) != 0) + { + _xController->restoreViewData(m_pImpl->m_xViewData->getByIndex(nCount - 1)); + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::disconnectController( const uno::Reference< frame::XController >& _xController ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + ::std::vector< uno::Reference< frame::XController> >::iterator aFind = ::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController); + if ( aFind != m_pImpl->m_aControllers.end() ) + m_pImpl->m_aControllers.erase(aFind); + if ( m_pImpl->m_xCurrentController == _xController ) + m_pImpl->m_xCurrentController.clear(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::lockControllers( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_bControllersLocked = sal_True; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::unlockControllers( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_bControllersLocked = sal_False; +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::hasControllersLocked( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_bControllersLocked; +} +// ----------------------------------------------------------------------------- +uno::Reference< frame::XController > SAL_CALL OReportDefinition::getCurrentController( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_xCurrentController; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setCurrentController( const uno::Reference< frame::XController >& _xController ) throw (container::NoSuchElementException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( ::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController) == m_pImpl->m_aControllers.end() ) + throw container::NoSuchElementException(); + m_pImpl->m_xCurrentController = _xController; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::getCurrentSelection( ) throw (uno::RuntimeException) +{ + return uno::Reference< uno::XInterface >(); +} +// ----------------------------------------------------------------------------- + +void OReportDefinition::impl_loadFromStorage_nolck_throw( const uno::Reference< embed::XStorage >& _xStorageToLoadFrom, + const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor ) +{ +// ::osl::MutexGuard aGuard(m_aMutex); +// ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); +// + + m_pImpl->m_xStorage = _xStorageToLoadFrom; + + ::comphelper::MediaDescriptor aDescriptor( _aMediaDescriptor ); + fillArgs(aDescriptor); + aDescriptor.createItemIfMissing(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage")),uno::makeAny(_xStorageToLoadFrom)); + + uno::Sequence< uno::Any > aDelegatorArguments(_aMediaDescriptor.getLength()); + uno::Any* pIter = aDelegatorArguments.getArray(); + uno::Any* pEnd = pIter + aDelegatorArguments.getLength(); + for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i) + { + *pIter <<= _aMediaDescriptor[i]; + } + sal_Int32 nPos = aDelegatorArguments.getLength(); + aDelegatorArguments.realloc(nPos+1); + beans::PropertyValue aPropVal; + aPropVal.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage")); + aPropVal.Value <<= _xStorageToLoadFrom; + aDelegatorArguments[nPos] <<= aPropVal; + + rptui::OXUndoEnvironment& rEnv = m_pImpl->m_pReportModel->GetUndoEnv(); + rptui::OXUndoEnvironment::OUndoEnvLock aLock(rEnv); + { + uno::Reference< document::XFilter > xFilter( + m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OReportFilter")),aDelegatorArguments,m_aProps->m_xContext), + uno::UNO_QUERY_THROW ); + + uno::Reference< document::XImporter> xImporter(xFilter,uno::UNO_QUERY_THROW); + uno::Reference<XComponent> xComponent(static_cast<OWeakObject*>(this),uno::UNO_QUERY); + xImporter->setTargetDocument(xComponent); + + ::comphelper::MediaDescriptor aTemp; + aTemp << aDelegatorArguments; + xFilter->filter(aTemp.getAsConstPropertyValueList()); + + lcl_setModelReadOnly(m_pImpl->m_xStorage,m_pImpl->m_pReportModel); + m_pImpl->m_pObjectContainer->SwitchPersistence(m_pImpl->m_xStorage); + } +} +// XStorageBasedDocument +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::loadFromStorage( const uno::Reference< embed::XStorage >& _xStorageToLoadFrom + , const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor ) throw (lang::IllegalArgumentException, frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + impl_loadFromStorage_nolck_throw( _xStorageToLoadFrom, _aMediaDescriptor ); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XStorage >& _xStorageToSaveTo, const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor ) throw (lang::IllegalArgumentException, io::IOException, uno::Exception, uno::RuntimeException) +{ + if ( !_xStorageToSaveTo.is() ) + throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_aProps->m_xContext->getServiceManager()),*this,1); + + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + // create XStatusIndicator + uno::Reference<task::XStatusIndicator> xStatusIndicator; + uno::Sequence< uno::Any > aDelegatorArguments; + ::comphelper::MediaDescriptor aDescriptor( _aMediaDescriptor ); + lcl_extractAndStartStatusIndicator( aDescriptor, xStatusIndicator, aDelegatorArguments ); + + // properties + uno::Sequence < beans::PropertyValue > aProps; + + // export sub streams for package, else full stream into a file + sal_Bool bWarn = sal_False, bErr = sal_False; + ::rtl::OUString sWarnFile, sErrFile; + + uno::Reference< beans::XPropertySet> xProp(_xStorageToSaveTo,uno::UNO_QUERY); + if ( xProp.is() ) + { + static const ::rtl::OUString sPropName(RTL_CONSTASCII_USTRINGPARAM("MediaType")); + ::rtl::OUString sOldMediaType; + xProp->getPropertyValue(sPropName) >>= sOldMediaType; + if ( !xProp->getPropertyValue(sPropName).hasValue() || !sOldMediaType.getLength() || MIMETYPE_OASIS_OPENDOCUMENT_REPORT != sOldMediaType ) + xProp->setPropertyValue( sPropName, uno::makeAny(MIMETYPE_OASIS_OPENDOCUMENT_REPORT) ); + } + + /** property map for export info set */ + comphelper::PropertyMapEntry aExportInfoMap[] = + { + { MAP_LEN( "UsePrettyPrinting" ), 0, &::getCppuType((sal_Bool*)0), beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN( "StreamName") , 0,&::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN( "StreamRelPath") , 0,&::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN( "BaseURI") , 0,&::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 }, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); + + SvtSaveOptions aSaveOpt; + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting")), uno::makeAny(aSaveOpt.IsPrettyPrinting())); + if ( aSaveOpt.IsSaveRelFSys() ) + { + const ::rtl::OUString sVal( aDescriptor.getUnpackedValueOrDefault(aDescriptor.PROP_DOCUMENTBASEURL(),::rtl::OUString()) ); + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(sVal)); + } // if ( aSaveOpt.IsSaveRelFSys() ) + const ::rtl::OUString sHierarchicalDocumentName( aDescriptor.getUnpackedValueOrDefault(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HierarchicalDocumentName")),::rtl::OUString()) ); + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath")), uno::makeAny(sHierarchicalDocumentName)); + + + sal_Int32 nArgsLen = aDelegatorArguments.getLength(); + aDelegatorArguments.realloc(nArgsLen+1); + aDelegatorArguments[nArgsLen++] <<= xInfoSet; + + uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver; + uno::Reference< document::XGraphicObjectResolver > xGrfResolver; + SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(_xStorageToSaveTo,GRAPHICHELPER_MODE_WRITE); + xGrfResolver = pGraphicHelper; + pGraphicHelper->release(); + SvXMLEmbeddedObjectHelper* pEmbeddedObjectHelper = SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE ); + xObjectResolver = pEmbeddedObjectHelper; + pEmbeddedObjectHelper->release(); + + aDelegatorArguments.realloc(nArgsLen+2); + aDelegatorArguments[nArgsLen++] <<= xGrfResolver; + aDelegatorArguments[nArgsLen++] <<= xObjectResolver; + + uno::Reference<XComponent> xCom(static_cast<OWeakObject*>(this),uno::UNO_QUERY); + if( !bErr ) + { + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("settings.xml")))); + if( !WriteThroughComponent( + xCom, "settings.xml", + "com.sun.star.comp.report.XMLSettingsExporter", + aDelegatorArguments, aProps, sal_True,_xStorageToSaveTo ) ) + { + if( !bWarn ) + { + bWarn = sal_True; + sWarnFile = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("settings.xml")); + } + } + } + + if( !bErr ) + { + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("meta.xml")))); + if( !WriteThroughComponent( + xCom, "meta.xml", + "com.sun.star.comp.report.XMLMetaExporter", + aDelegatorArguments, aProps, sal_True,_xStorageToSaveTo ) ) + { + if( !bWarn ) + { + bWarn = sal_True; + sWarnFile = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("meta.xml")); + } + } + } // if( !bErr ) + + if( !bErr ) + { + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("styles.xml")))); + if( !WriteThroughComponent( + xCom, "styles.xml", + "com.sun.star.comp.report.XMLStylesExporter", + aDelegatorArguments, aProps, sal_True,_xStorageToSaveTo ) ) + { + if( !bWarn ) + { + bWarn = sal_True; + sWarnFile = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("styles.xml")); + } + } + } + + if ( !bErr ) + { + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml")))); + if( !WriteThroughComponent( + xCom, "content.xml", + "com.sun.star.comp.report.ExportFilter", + aDelegatorArguments, aProps, sal_True,_xStorageToSaveTo ) ) + { + bErr = sal_True; + sErrFile = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml")); + } + } // if ( !bErr ) + + uno::Any aImage; + uno::Reference< embed::XVisualObject > xCurrentController(getCurrentController(),uno::UNO_QUERY); + if ( xCurrentController.is() ) + { + xCurrentController->setVisualAreaSize(m_pImpl->m_nAspect,m_pImpl->m_aVisualAreaSize); + aImage = xCurrentController->getPreferredVisualRepresentation( m_pImpl->m_nAspect ).Data; + } + if ( aImage.hasValue() ) + { + ::rtl::OUString sObject1(RTL_CONSTASCII_USTRINGPARAM("report")); + ::rtl::OUString sPng(RTL_CONSTASCII_USTRINGPARAM("image/png")); + + uno::Sequence<sal_Int8> aSeq; + aImage >>= aSeq; + uno::Reference<io::XInputStream> xStream = new ::comphelper::SequenceInputStream( aSeq ); + m_pImpl->m_pObjectContainer->InsertGraphicStreamDirectly(xStream,sObject1,sPng); + } + + if ( !bErr ) + { + sal_Bool bPersist = sal_False; + if ( _xStorageToSaveTo == m_pImpl->m_xStorage ) + bPersist = m_pImpl->m_pObjectContainer->StoreChildren(sal_True,sal_False); + else + bPersist = m_pImpl->m_pObjectContainer->StoreAsChildren(sal_True,sal_True,_xStorageToSaveTo); + + if( bPersist ) + m_pImpl->m_pObjectContainer->SetPersistentEntries(m_pImpl->m_xStorage); + try + { + uno::Reference<embed::XTransactedObject> xTransact(_xStorageToSaveTo,uno::UNO_QUERY); + if ( xTransact.is() ) + xTransact->commit(); + } + catch(uno::Exception) + { + OSL_ENSURE(0,"Exception Caught: Could not commit report storage!"); + throw io::IOException(); + } + + if ( _xStorageToSaveTo == m_pImpl->m_xStorage ) + setModified(sal_False); + } + if ( xStatusIndicator.is() ) + xStatusIndicator->end(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::switchToStorage( const uno::Reference< embed::XStorage >& _xStorage ) throw (lang::IllegalArgumentException, io::IOException, uno::Exception, uno::RuntimeException) +{ + if ( !_xStorage.is() ) + throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_aProps->m_xContext->getServiceManager()),*this,1); + { + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_xStorage = _xStorage; + lcl_setModelReadOnly(m_pImpl->m_xStorage,m_pImpl->m_pReportModel); + m_pImpl->m_pObjectContainer->SwitchPersistence(m_pImpl->m_xStorage); + } + // notify our container listeners + m_pImpl->m_aStorageChangeListeners.forEach<document::XStorageChangeListener>( + ::boost::bind(&document::XStorageChangeListener::notifyStorageChange,_1,boost::cref(static_cast<OWeakObject*>(this)),boost::cref(_xStorage))); +} +// ----------------------------------------------------------------------------- +uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentStorage( ) throw (io::IOException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_xStorage; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::addStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( xListener.is() ) + m_pImpl->m_aStorageChangeListeners.addInterface(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::removeStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_aStorageChangeListeners.removeInterface(xListener); +} +// ----------------------------------------------------------------------------- +sal_Bool OReportDefinition::WriteThroughComponent( + const uno::Reference<lang::XComponent> & xComponent, + const sal_Char* pStreamName, + const sal_Char* pServiceName, + const uno::Sequence<uno::Any> & rArguments, + const uno::Sequence<beans::PropertyValue> & rMediaDesc, + sal_Bool bPlainStream + ,const uno::Reference<embed::XStorage>& _xStorageToSaveTo) +{ + OSL_ENSURE( NULL != pStreamName, "Need stream name!" ); + OSL_ENSURE( NULL != pServiceName, "Need service name!" ); + try + { + uno::Reference<embed::XStorage> xMyStorage = _xStorageToSaveTo; + // open stream + ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii( pStreamName ); + uno::Reference<io::XStream> xStream = xMyStorage->openStreamElement( sStreamName,embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); + if ( !xStream.is() ) + return sal_False; + uno::Reference<io::XOutputStream> xOutputStream = xStream->getOutputStream(); + OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!"); + if ( ! xOutputStream.is() ) + return sal_False; + + uno::Reference<beans::XPropertySet> xStreamProp(xOutputStream,uno::UNO_QUERY); + OSL_ENSURE(xStreamProp.is(),"No valid preoperty set for the output stream!"); + + uno::Reference<io::XSeekable> xSeek(xStreamProp,uno::UNO_QUERY); + if ( xSeek.is() ) + { + OSL_TRACE("Length of stream %i",(int)xSeek->getPosition()); + xSeek->seek(0); + } + + ::rtl::OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("MediaType")); + ::rtl::OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") ); + uno::Any aAny; + aAny <<= aMime; + xStreamProp->setPropertyValue( aPropName, aAny ); + + if( bPlainStream ) + { + aAny <<= sal_False; + xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Compressed") ), aAny ); + } + else + { + xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ), uno::makeAny(sal_True) ); + } + + + // set buffer and create outputstream + + // write the stuff + sal_Bool bRet = WriteThroughComponent( + xOutputStream, xComponent, + pServiceName, rArguments, rMediaDesc ); + // finally, commit stream. + return bRet; + } + catch(const uno::Exception& e) + { + (void)e; // helper to know what e contains + throw; + } +} +// ----------------------------------------------------------------------------- +sal_Bool OReportDefinition::WriteThroughComponent( + const uno::Reference<io::XOutputStream> & xOutputStream, + const uno::Reference<lang::XComponent> & xComponent, + const sal_Char* pServiceName, + const uno::Sequence<uno::Any> & rArguments, + const uno::Sequence<beans::PropertyValue> & rMediaDesc) +{ + OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" ); + OSL_ENSURE( xComponent.is(), "Need component!" ); + OSL_ENSURE( NULL != pServiceName, "Need component name!" ); + + // get component + uno::Reference< io::XActiveDataSource > xSaxWriter( + m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer")),m_aProps->m_xContext), + uno::UNO_QUERY ); + OSL_ENSURE( xSaxWriter.is(), "can't instantiate XML com.sun.star.xml.sax.Writer" ); + if(!xSaxWriter.is()) + return sal_False; + + // connect XML writer to output stream + xSaxWriter->setOutputStream( xOutputStream ); + + // prepare arguments (prepend doc handler to given arguments) + uno::Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,uno::UNO_QUERY); + uno::Sequence<uno::Any> aArgs( 1 + rArguments.getLength() ); + aArgs[0] <<= xDocHandler; + for(sal_Int32 i = 0; i < rArguments.getLength(); i++) + aArgs[i+1] = rArguments[i]; + + // get filter component + uno::Reference< document::XExporter > xExporter( + m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + ::rtl::OUString::createFromAscii(pServiceName), aArgs,m_aProps->m_xContext), uno::UNO_QUERY); + OSL_ENSURE( xExporter.is(), + "can't instantiate export filter component" ); + if( !xExporter.is() ) + return sal_False; + + // connect model and filter + xExporter->setSourceDocument( xComponent ); + + // filter! + uno::Reference<document::XFilter> xFilter( xExporter, uno::UNO_QUERY ); + return xFilter->filter( rMediaDesc ); +} +// ----------------------------------------------------------------------------- +// XLoadable +void SAL_CALL OReportDefinition::initNew( ) throw (frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException) +{ + setPageHeaderOn( sal_True ); + setPageFooterOn( sal_True ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue >& _rArguments ) throw (frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage, + // perhaps we can share code here. + + ::comphelper::NamedValueCollection aArguments( _rArguments ); + + // the source for the to-be-created storage: either an URL, or a stream + uno::Reference< io::XInputStream > xStream; + ::rtl::OUString sURL; + + if ( aArguments.has( "Stream" ) ) + { + aArguments.get_ensureType( "Stream", xStream ); + aArguments.remove( "Stream" ); + } + else if ( aArguments.has( "InputStream" ) ) + { + aArguments.get_ensureType( "InputStream", xStream ); + aArguments.remove( "InputStream" ); + } + + if ( aArguments.has( "FileName" ) ) + { + aArguments.get_ensureType( "FileName", sURL ); + aArguments.remove( "FileName" ); + } + else if ( aArguments.has( "URL" ) ) + { + aArguments.get_ensureType( "URL", sURL ); + aArguments.remove( "URL" ); + } + + uno::Any aStorageSource; + if ( xStream.is() ) + aStorageSource <<= aStorageSource; + else if ( sURL.getLength() ) + aStorageSource <<= sURL; + else + // TODO: error message + throw lang::IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No input source (URL or InputStream) found." ) ), + // TODO: resource + *this, + 1 + ); + + uno::Reference< lang::XSingleServiceFactory > xStorageFactory( + m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.StorageFactory" ) ), + m_aProps->m_xContext ), + uno::UNO_QUERY_THROW + ); + + // open read-write per default, unless told otherwise in the MediaDescriptor + uno::Reference< embed::XStorage > xDocumentStorage; + const sal_Int32 nOpenModes[2] = { + embed::ElementModes::READWRITE, + embed::ElementModes::READ + }; + size_t nFirstOpenMode = 0; + if ( aArguments.has( "ReadOnly" ) ) + { + sal_Bool bReadOnly = sal_False; + aArguments.get_ensureType( "ReadOnly", bReadOnly ); + nFirstOpenMode = bReadOnly ? 1 : 0; + } + const size_t nLastOpenMode = sizeof( nOpenModes ) / sizeof( nOpenModes[0] ) - 1; + for ( size_t i=nFirstOpenMode; i <= nLastOpenMode; ++i ) + { + uno::Sequence< uno::Any > aStorageCreationArgs(2); + aStorageCreationArgs[0] = aStorageSource; + aStorageCreationArgs[1] <<= nOpenModes[i]; + + try + { + xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), uno::UNO_QUERY_THROW ); + } + catch( const uno::Exception& ) + { + if ( i == nLastOpenMode ) + throw lang::WrappedTargetException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "An error occured while creating the document storage." ) ), + // TODO: resource + *this, + ::cppu::getCaughtException() + ); + } + } + + if ( !xDocumentStorage.is() ) + { + throw uno::RuntimeException(); + } + + impl_loadFromStorage_nolck_throw( xDocumentStorage, aArguments.getPropertyValues() ); + // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage + // ourself here, and perhaps this means we're also responsible for it ...? +} +// ----------------------------------------------------------------------------- +// XVisualObject +void SAL_CALL OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + //if( nAspect == embed::Aspects::MSOLE_CONTENT ) + { + bool bChanged = + (m_pImpl->m_aVisualAreaSize.Width != _aSize.Width || + m_pImpl->m_aVisualAreaSize.Height != _aSize.Height); + m_pImpl->m_aVisualAreaSize = _aSize; + if( bChanged ) + setModified( sal_True ); + } + m_pImpl->m_nAspect = _nAspect; +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OReportDefinition::getVisualAreaSize( ::sal_Int64 /*_nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_aVisualAreaSize; +} +// ----------------------------------------------------------------------------- +embed::VisualRepresentation SAL_CALL OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64 /*_nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + embed::VisualRepresentation aResult; + ::rtl::OUString sImageName(RTL_CONSTASCII_USTRINGPARAM("report")); + ::rtl::OUString sMimeType; + uno::Reference<io::XInputStream> xStream = m_pImpl->m_pObjectContainer->GetGraphicStream(sImageName,&sMimeType); + if ( xStream.is() ) + { + uno::Sequence<sal_Int8> aSeq; + xStream->readBytes(aSeq,xStream->available()); + xStream->closeInput(); + aResult.Data <<= aSeq; + aResult.Flavor.MimeType = sMimeType; + aResult.Flavor.DataType = ::getCppuType( &aSeq ); + } + + return aResult; +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OReportDefinition::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException) +{ + return embed::EmbedMapUnits::ONE_100TH_MM; +} +// ----------------------------------------------------------------------------- +// XModifiable +::sal_Bool SAL_CALL OReportDefinition::disableSetModified( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed ); + + const sal_Bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled; + m_pImpl->m_bSetModifiedEnabled = sal_False; + return bWasEnabled; +} + +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::enableSetModified( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed ); + + const sal_Bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled; + m_pImpl->m_bSetModifiedEnabled = sal_True; + return bWasEnabled; +} + +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::isSetModifiedEnabled( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed ); + + return m_pImpl->m_bSetModifiedEnabled; +} + +// ----------------------------------------------------------------------------- +// XModifiable +::sal_Bool SAL_CALL OReportDefinition::isModified( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_bModified; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setModified( ::sal_Bool _bModified ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + ::osl::ResettableMutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + if ( !m_pImpl->m_bSetModifiedEnabled ) + return; + + if ( m_pImpl->m_pReportModel->IsReadOnly() && _bModified ) + throw beans::PropertyVetoException(); + if ( m_pImpl->m_bModified != _bModified ) + { + m_pImpl->m_bModified = _bModified; + if ( m_pImpl->m_pReportModel->IsChanged() != _bModified ) + m_pImpl->m_pReportModel->SetChanged(_bModified); + + lang::EventObject aEvent(*this); + aGuard.clear(); + m_pImpl->m_aModifyListeners.notifyEach(&util::XModifyListener::modified,aEvent); + notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnModifyChanged"))); + } +} +// ----------------------------------------------------------------------------- +// XModifyBroadcaster +void SAL_CALL OReportDefinition::addModifyListener( const uno::Reference< util::XModifyListener >& _xListener ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( _xListener.is() ) + m_pImpl->m_aModifyListeners.addInterface(_xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::removeModifyListener( const uno::Reference< util::XModifyListener >& _xListener ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_aModifyListeners.removeInterface(_xListener); +} +// ----------------------------------------------------------------------------- +void OReportDefinition::notifyEvent(const ::rtl::OUString& _sEventName) +{ + try + { + ::osl::ResettableMutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + document::EventObject aEvt(*this, _sEventName); + aGuard.clear(); + m_pImpl->m_aDocEventListeners.notifyEach(&document::XEventListener::notifyEvent,aEvt); + } + catch(uno::Exception&) + { + } +} +// ----------------------------------------------------------------------------- +// document::XEventBroadcaster +void SAL_CALL OReportDefinition::addEventListener(const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( _xListener.is() ) + m_pImpl->m_aDocEventListeners.addInterface(_xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::removeEventListener( const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_aDocEventListeners.removeInterface(_xListener); +} +// ----------------------------------------------------------------------------- +// document::XEventListener +void SAL_CALL OReportDefinition::notifyEvent( const document::EventObject& aEvent ) throw (uno::RuntimeException) +{ + // used only to forward external events (e.g. for doc creation) from the frame loader + // to the global event broadcaster and all other interested doc event listener. + notifyEvent(aEvent.EventName); +} +// ----------------------------------------------------------------------------- +// document::XViewDataSupplier +uno::Reference< container::XIndexAccess > SAL_CALL OReportDefinition::getViewData( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( !m_pImpl->m_xViewData.is() ) + { + m_pImpl->m_xViewData.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")),m_aProps->m_xContext ),uno::UNO_QUERY); + //uno::Sequence< beans::PropertyValue > aProps; + //m_pImpl->m_xViewData->insertByIndex(m_pImpl->m_xViewData->getCount(),uno::makeAny(aProps)); + uno::Reference< container::XIndexContainer > xContainer(m_pImpl->m_xViewData,uno::UNO_QUERY); + ::std::vector< uno::Reference< frame::XController> >::iterator aIter = m_pImpl->m_aControllers.begin(); + ::std::vector< uno::Reference< frame::XController> >::iterator aEnd = m_pImpl->m_aControllers.end(); + for (;aIter != aEnd ; ++aIter) + { + if ( aIter->is() ) + { + try + { + xContainer->insertByIndex(xContainer->getCount(),(*aIter)->getViewData()); + } + catch(uno::Exception&) + { + } + } // if ( aIter->is() ) + } + + } + return m_pImpl->m_xViewData; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setViewData( const uno::Reference< container::XIndexAccess >& Data ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_xViewData = Data; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XFunctions > SAL_CALL OReportDefinition::getFunctions() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_xFunctions; +} +// ----------------------------------------------------------------------------- +uno::Reference< ui::XUIConfigurationManager > SAL_CALL OReportDefinition::getUIConfigurationManager( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + if ( !m_pImpl->m_xUIConfigurationManager.is() ) + { + m_pImpl->m_xUIConfigurationManager.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.UIConfigurationManager")),m_aProps->m_xContext), + uno::UNO_QUERY); + + uno::Reference< ui::XUIConfigurationStorage > xUIConfigStorage( m_pImpl->m_xUIConfigurationManager, uno::UNO_QUERY ); + if ( xUIConfigStorage.is() ) + { + uno::Reference< embed::XStorage > xConfigStorage; + // initialize ui configuration manager with document substorage + xUIConfigStorage->setStorage( xConfigStorage ); + } + } + + return m_pImpl->m_xUIConfigurationManager; +} +// ----------------------------------------------------------------------------- +uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_xStorage->openStorageElement(aStorageName, nMode); +} +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getDocumentSubStoragesNames( ) throw (io::IOException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + uno::Reference<container::XNameAccess> xNameAccess(m_pImpl->m_xStorage,uno::UNO_QUERY); + return xNameAccess.is() ? xNameAccess->getElementNames() : uno::Sequence< ::rtl::OUString >(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportDefinition::getMimeType() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_sMimeType; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setMimeType( const ::rtl::OUString& _mimetype ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + uno::Sequence< ::rtl::OUString > aList = getAvailableMimeTypes(); + const ::rtl::OUString* pEnd = aList.getConstArray()+aList.getLength(); + if ( ::std::find(aList.getConstArray(),pEnd,_mimetype) == pEnd ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getAvailableMimeTypes()")) + ,*this + ,1 + ,m_aProps->m_xContext); + set(PROPERTY_MIMETYPE,_mimetype,m_pImpl->m_sMimeType); +} +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getAvailableMimeTypes( ) throw (lang::DisposedException, uno::Exception, uno::RuntimeException) +{ + static uno::Sequence< ::rtl::OUString > s_aList; + if ( !s_aList.hasElements() ) + { + s_aList.realloc(2); + s_aList[0] = MIMETYPE_OASIS_OPENDOCUMENT_TEXT; + s_aList[1] = MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET; + } + + return s_aList; +} +// ----------------------------------------------------------------------------- +// com::sun::star::XUnoTunnel +sal_Int64 SAL_CALL OReportDefinition::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) +{ + sal_Int64 nRet = 0; + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + nRet = reinterpret_cast<sal_Int64>(this); + else + { + uno::Reference< lang::XUnoTunnel> xUnoTunnel(m_pImpl->m_xNumberFormatsSupplier,uno::UNO_QUERY); + if ( xUnoTunnel.is() ) + nRet = xUnoTunnel->getSomething(rId); + } + if ( !nRet ) + { + uno::Reference< lang::XUnoTunnel> xTunnel; + ::comphelper::query_aggregation(m_aProps->m_xProxy,xTunnel); + if ( xTunnel.is() ) + nRet = xTunnel->getSomething(rId); + } + + return nRet; +} +// ----------------------------------------------------------------------------- +uno::Sequence< sal_Int8 > SAL_CALL OReportDefinition::getImplementationId( ) throw (uno::RuntimeException) +{ + return OReportDefinition::getUnoTunnelImplementationId(); +} +//-------------------------------------------------------------------------- +uno::Sequence< sal_Int8 > OReportDefinition::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(); +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XComponentContext > OReportDefinition::getContext() +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_aProps->m_xContext; +} +// ----------------------------------------------------------------------------- +::boost::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel() const +{ + return m_pImpl->m_pReportModel; +} +// ----------------------------------------------------------------------------- +::boost::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel(const uno::Reference< report::XReportDefinition >& _xReportDefinition) +{ + ::boost::shared_ptr<rptui::OReportModel> pReportModel; + uno::Reference< lang::XUnoTunnel > xUT( _xReportDefinition, uno::UNO_QUERY ); + if( xUT.is() ) + pReportModel = reinterpret_cast<OReportDefinition*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( OReportDefinition::getUnoTunnelImplementationId())))->getSdrModel(); + return pReportModel; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& _aArgs) + throw( uno::Exception, uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + uno::Reference< uno::XInterface > xRet; + if ( aServiceSpecifier.indexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver"))) == 0 ) + { + uno::Reference< embed::XStorage > xStorage; + const uno::Any* pIter = _aArgs.getConstArray(); + const uno::Any* pEnd = pIter + _aArgs.getLength(); + for(;pIter != pEnd ;++pIter) + { + beans::NamedValue aValue; + *pIter >>= aValue; + if( aValue.Name.equalsAscii( "Storage" ) ) + aValue.Value >>= xStorage; + } // for(;pIter != pEnd ;++pIter) + m_pImpl->m_pObjectContainer->SwitchPersistence(xStorage); + xRet = static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_READ )); + } + return xRet; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + uno::Reference< drawing::XShape > xShape; + if ( aServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.report.") ) == 0 ) + { + if ( aServiceSpecifier == SERVICE_SHAPE ) + xShape.set(SvxUnoDrawMSFactory::createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CustomShape")) ),uno::UNO_QUERY_THROW); + else if ( aServiceSpecifier == SERVICE_FORMATTEDFIELD + || aServiceSpecifier == SERVICE_FIXEDTEXT + || aServiceSpecifier == SERVICE_FIXEDLINE + || aServiceSpecifier == SERVICE_IMAGECONTROL ) + xShape.set(SvxUnoDrawMSFactory::createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape")) ),uno::UNO_QUERY_THROW); + else + xShape.set(SvxUnoDrawMSFactory::createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")) ),uno::UNO_QUERY_THROW); + } + else if ( aServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.form.component.") ) == 0 ) + { + xShape.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier,m_aProps->m_xContext),uno::UNO_QUERY); + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.PageStyle") ) == 0 || + aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.FrameStyle") ) == 0 || + aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.GraphicStyle") ) == 0 + ) + { + uno::Reference< style::XStyle> xStyle = new OStyle(); + xStyle->setName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Default"))); + uno::Reference<beans::XPropertySet> xProp(xStyle,uno::UNO_QUERY); + ::rtl::OUString sTray; + xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrinterPaperTray")))>>= sTray; + + return xStyle.get(); + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) == 0 ) + { + uno::Reference<beans::XPropertySet> xProp = new OStyle(); + + return xProp.get(); + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) == 0 ) + { + uno::Reference<beans::XPropertySet> xProp = new OStyle(); + return xProp.get(); + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) == 0 ) + { + if ( !m_pImpl->m_xGradientTable.is() ) + m_pImpl->m_xGradientTable.set(SvxUnoGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY); + //comphelper::NameContainer_createInstance( ::getCppuType( (const awt::Gradient*) 0 ) ).get(); + return m_pImpl->m_xGradientTable; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) == 0 ) + { + if ( !m_pImpl->m_xHatchTable.is() ) + m_pImpl->m_xHatchTable.set(SvxUnoHatchTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY); + //comphelper::NameContainer_createInstance( ::getCppuType( (const drawing::Hatch*) 0 ) ).get(); + return m_pImpl->m_xHatchTable; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) == 0 ) + { + if ( !m_pImpl->m_xBitmapTable.is() ) + m_pImpl->m_xBitmapTable.set(SvxUnoBitmapTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY); + //comphelper::NameContainer_createInstance( ::getCppuType( (const ::rtl::OUString*) 0 ) ).get(); + return m_pImpl->m_xBitmapTable; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) == 0 ) + { + if ( !m_pImpl->m_xTransparencyGradientTable.is() ) + m_pImpl->m_xTransparencyGradientTable.set(SvxUnoTransGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY); + //comphelper::NameContainer_createInstance( ::getCppuType( (const awt::Gradient*) 0 ) ).get(); + return m_pImpl->m_xTransparencyGradientTable; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) == 0 ) + { + if ( !m_pImpl->m_xDashTable.is() ) + m_pImpl->m_xDashTable.set(SvxUnoDashTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY); + //comphelper::NameContainer_createInstance( ::getCppuType( (const drawing::LineDash*) 0 ) ).get(); + return m_pImpl->m_xDashTable; + } + else if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) ) + { + if( !m_pImpl->m_xMarkerTable.is() ) + m_pImpl->m_xMarkerTable.set(SvxUnoMarkerTable_createInstance( m_pImpl->m_pReportModel.get() ),uno::UNO_QUERY); + return m_pImpl->m_xMarkerTable; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")) == 0 ) + return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_READ )); + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver")) == 0 ) + return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE )); + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver")) == 0 ) + { + SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,GRAPHICHELPER_MODE_WRITE); + uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(pGraphicHelper)); + pGraphicHelper->release(); + return xRet; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver")) == 0 ) + { + SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,GRAPHICHELPER_MODE_WRITE); + uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(pGraphicHelper)); + pGraphicHelper->release(); + return xRet; + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider")) == 0 ) + { + uno::Reference<chart2::data::XDatabaseDataProvider> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps->m_xContext, m_pImpl->m_xActiveConnection )); + xDataProvider->setRowLimit(10); + uno::Reference< container::XChild > xChild(xDataProvider,uno::UNO_QUERY); + if ( xChild.is() ) + xChild->setParent(*this); + return uno::Reference< uno::XInterface >(xDataProvider,uno::UNO_QUERY); + } + else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.xml.NamespaceMap")) == 0 ) + { + if ( !m_pImpl->m_xXMLNamespaceMap.is() ) + m_pImpl->m_xXMLNamespaceMap = comphelper::NameContainer_createInstance( ::getCppuType( (const ::rtl::OUString*) 0 ) ).get(); + return m_pImpl->m_xXMLNamespaceMap; + } + else + xShape.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier ),uno::UNO_QUERY_THROW); + + return m_pImpl->m_pReportModel->createShape(aServiceSpecifier,xShape); +} +//----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getAvailableServiceNames(void) throw( uno::RuntimeException ) +{ + static const ::rtl::OUString aSvxComponentServiceNameList[] = + { + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.GraphicStyle")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.NamespaceMap")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.Settings")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable")) + }; + + static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] ); + + uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount ); + ::rtl::OUString* pStrings = aSeq.getArray(); + for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ ) + pStrings[nIdx] = aSvxComponentServiceNameList[nIdx]; + + uno::Sequence< ::rtl::OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() ); + return concatServiceNames( aParentSeq, aSeq ); +} +// ----------------------------------------------------------------------------- +// XShape +awt::Point SAL_CALL OReportDefinition::getPosition( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( m_aProps->m_xShape.is() ) + return m_aProps->m_xShape->getPosition(); + return awt::Point(m_aProps->m_nPosX,m_aProps->m_nPosY); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( m_aProps->m_xShape.is() ) + m_aProps->m_xShape->setPosition(aPosition); + set(PROPERTY_POSITIONX,aPosition.X,m_aProps->m_nPosX); + set(PROPERTY_POSITIONY,aPosition.Y,m_aProps->m_nPosY); +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OReportDefinition::getSize( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( m_aProps->m_xShape.is() ) + return m_aProps->m_xShape->getSize(); + return awt::Size(m_aProps->m_nWidth,m_aProps->m_nHeight); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( m_aProps->m_xShape.is() ) + m_aProps->m_xShape->setSize(aSize); + set(PROPERTY_WIDTH,aSize.Width,m_aProps->m_nWidth); + set(PROPERTY_HEIGHT,aSize.Height,m_aProps->m_nHeight); +} +// ----------------------------------------------------------------------------- + +// XShapeDescriptor +::rtl::OUString SAL_CALL OReportDefinition::getShapeType( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( m_aProps->m_xShape.is() ) + return m_aProps->m_xShape->getShapeType(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +typedef ::cppu::WeakImplHelper2< container::XNameContainer, + container::XIndexAccess + > TStylesBASE; +class OStylesHelper : public ::cppu::BaseMutex, public TStylesBASE +{ + typedef ::std::map< ::rtl::OUString, uno::Any , ::comphelper::UStringMixLess> TStyleElements; + TStyleElements m_aElements; + ::std::vector<TStyleElements::iterator> m_aElementsPos; + uno::Type m_aType; + + OStylesHelper(const OStylesHelper&); + void operator =(const OStylesHelper&); +protected: + virtual ~OStylesHelper(){} +public: + OStylesHelper(const uno::Type _aType = ::getCppuType(static_cast< uno::Reference< container::XElementAccess >* >(NULL))); + + // XNameContainer + virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException); + virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(container::NoSuchElementException, lang::WrappedTargetException,uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException,lang::WrappedTargetException, uno::RuntimeException); + + // container::XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException); + // container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) throw(uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException); + + // container::XNameAccess + virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException); +}; + +OStylesHelper::OStylesHelper(const uno::Type _aType) +: cppu::BaseMutex() +,m_aType(_aType) +{ +} +// -----------------------------------------------------------------------------; +// container::XElementAccess +uno::Type SAL_CALL OStylesHelper::getElementType( ) throw(uno::RuntimeException) +{ + return m_aType; +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OStylesHelper::hasElements( ) throw(uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return !m_aElementsPos.empty(); +} +// ----------------------------------------------------------------------------- +// container::XIndexAccess +sal_Int32 SAL_CALL OStylesHelper::getCount( ) throw(uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aElementsPos.size(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OStylesHelper::getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( Index < 0 || Index >= static_cast<sal_Int32>(m_aElementsPos.size()) ) + throw lang::IndexOutOfBoundsException(); + return uno::makeAny(m_aElementsPos[Index]->second); +} +// ----------------------------------------------------------------------------- +// container::XNameAccess +uno::Any SAL_CALL OStylesHelper::getByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + TStyleElements::iterator aFind = m_aElements.find(aName); + if ( aFind == m_aElements.end() ) + throw container::NoSuchElementException(); + return uno::makeAny(aFind->second); +} +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OStylesHelper::getElementNames( ) throw(uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + uno::Sequence< ::rtl::OUString > aNameList(m_aElementsPos.size()); + + ::rtl::OUString* pStringArray = aNameList.getArray(); + ::std::vector<TStyleElements::iterator>::const_iterator aEnd = m_aElementsPos.end(); + for(::std::vector<TStyleElements::iterator>::const_iterator aIter = m_aElementsPos.begin(); aIter != aEnd;++aIter,++pStringArray) + *pStringArray = (*aIter)->first; + + return aNameList; +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OStylesHelper::hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aElements.find(aName) != m_aElements.end(); +} +// ----------------------------------------------------------------------------- +// XNameContainer +void SAL_CALL OStylesHelper::insertByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_aElements.find(aName) != m_aElements.end() ) + throw container::ElementExistException(); + + if ( !aElement.isExtractableTo(m_aType) ) + throw lang::IllegalArgumentException(); + + m_aElementsPos.push_back(m_aElements.insert(TStyleElements::value_type(aName,aElement)).first); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStylesHelper::removeByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException,uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + TStyleElements::iterator aFind = m_aElements.find(aName); + if ( aFind != m_aElements.end() ) + throw container::NoSuchElementException(); + m_aElementsPos.erase(::std::find(m_aElementsPos.begin(),m_aElementsPos.end(),aFind)); + m_aElements.erase(aFind); +} +// ----------------------------------------------------------------------------- +// XNameReplace +void SAL_CALL OStylesHelper::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException,lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + TStyleElements::iterator aFind = m_aElements.find(aName); + if ( aFind != m_aElements.end() ) + throw container::NoSuchElementException(); + if ( !aElement.isExtractableTo(m_aType) ) + throw lang::IllegalArgumentException(); + aFind->second = aElement; +} +// ----------------------------------------------------------------------------- +uno::Reference< container::XNameAccess > SAL_CALL OReportDefinition::getStyleFamilies( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( !m_pImpl->m_xStyles.is() ) + { + m_pImpl->m_xStyles = new OStylesHelper(); + uno::Reference< container::XNameContainer> xStyles(m_pImpl->m_xStyles,uno::UNO_QUERY); + + uno::Reference< container::XNameContainer> xPageStyles = new OStylesHelper(::getCppuType(static_cast< uno::Reference<style::XStyle>* >(NULL))); + xStyles->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles")),uno::makeAny(xPageStyles)); + uno::Reference< style::XStyle> xPageStyle(createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle"))),uno::UNO_QUERY); + xPageStyles->insertByName(xPageStyle->getName(),uno::makeAny(xPageStyle)); + + uno::Reference< container::XNameContainer> xFrameStyles = new OStylesHelper(::getCppuType(static_cast< uno::Reference<style::XStyle>* >(NULL))); + xStyles->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameStyles")),uno::makeAny(xFrameStyles)); + uno::Reference< style::XStyle> xFrameStyle(createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle"))),uno::UNO_QUERY); + xFrameStyles->insertByName(xFrameStyle->getName(),uno::makeAny(xFrameStyle)); + + uno::Reference< container::XNameContainer> xGraphicStyles = new OStylesHelper(::getCppuType(static_cast< uno::Reference<style::XStyle>* >(NULL))); + xStyles->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("graphics")),uno::makeAny(xGraphicStyles)); + uno::Reference< style::XStyle> xGraphicStyle(createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.GraphicStyle"))),uno::UNO_QUERY); + xGraphicStyles->insertByName(xGraphicStyle->getName(),uno::makeAny(xGraphicStyle)); + } + return m_pImpl->m_xStyles; +} +::rtl::OUString SAL_CALL OReportDefinition::getIdentifier( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + return m_pImpl->m_sIdentifier; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setIdentifier( const ::rtl::OUString& Identifier ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + m_pImpl->m_sIdentifier = Identifier; +} +// ----------------------------------------------------------------------------- +// XNumberFormatsSupplier +uno::Reference< beans::XPropertySet > SAL_CALL OReportDefinition::getNumberFormatSettings( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_pImpl->m_xNumberFormatsSupplier.is() ) + return m_pImpl->m_xNumberFormatsSupplier->getNumberFormatSettings(); + return uno::Reference< beans::XPropertySet >(); +} +// ----------------------------------------------------------------------------- +uno::Reference< util::XNumberFormats > SAL_CALL OReportDefinition::getNumberFormats( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_pImpl->m_xNumberFormatsSupplier.is() ) + return m_pImpl->m_xNumberFormatsSupplier->getNumberFormats(); + return uno::Reference< util::XNumberFormats >(); +} +// ----------------------------------------------------------------------------- +::comphelper::EmbeddedObjectContainer& OReportDefinition::getEmbeddedObjectContainer() const +{ + return *m_pImpl->m_pObjectContainer; +} +// ----------------------------------------------------------------------------- +uno::Reference< embed::XStorage > OReportDefinition::getStorage() const +{ + return m_pImpl->m_xStorage; +} +// ----------------------------------------------------------------------------- +uno::Reference< task::XInteractionHandler > OReportDefinition::getInteractionHandler() const +{ + uno::Reference< task::XInteractionHandler > xRet( m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler")) ,m_aProps->m_xContext),uno::UNO_QUERY); + return xRet; +} +// ----------------------------------------------------------------------------- +uno::Reference< sdbc::XConnection > SAL_CALL OReportDefinition::getActiveConnection() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_pImpl->m_xActiveConnection; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setActiveConnection( const uno::Reference< sdbc::XConnection >& _activeconnection ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + if ( !_activeconnection.is() ) + throw lang::IllegalArgumentException(); + set(PROPERTY_ACTIVECONNECTION,_activeconnection,m_pImpl->m_xActiveConnection); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportDefinition::getDataSourceName() throw (uno::RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_pImpl->m_sDataSourceName; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportDefinition::setDataSourceName(const ::rtl::OUString& the_value) throw (uno::RuntimeException) +{ + set(PROPERTY_DATASOURCENAME,the_value,m_pImpl->m_sDataSourceName); +} +// ----------------------------------------------------------------------------- +bool OReportDefinition::isEnableSetModified() const +{ + return true; +} +uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw() +{ + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + if ( ! m_pImpl->m_xTitleHelper.is ()) + { + uno::Reference< frame::XUntitledNumbers > xDesktop(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop")) ,m_aProps->m_xContext),uno::UNO_QUERY_THROW); + uno::Reference< frame::XModel > xThis (static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW); + + ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(uno::Reference< lang::XMultiServiceFactory >(m_aProps->m_xContext->getServiceManager(),uno::UNO_QUERY)); + m_pImpl->m_xTitleHelper = uno::Reference< frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW); + pHelper->setOwner (xThis ); + pHelper->connectWithUntitledNumbers (xDesktop); + } + + return m_pImpl->m_xTitleHelper; +} +// ----------------------------------------------------------------------------- +uno::Reference< frame::XUntitledNumbers > OReportDefinition::impl_getUntitledHelper_throw() +{ + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + if ( ! m_pImpl->m_xNumberedControllers.is ()) + { + uno::Reference< frame::XModel > xThis (static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW); + ::comphelper::NumberedCollection* pHelper = new ::comphelper::NumberedCollection(); + m_pImpl->m_xNumberedControllers = uno::Reference< frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW); + + pHelper->setOwner (xThis); + pHelper->setUntitledPrefix (::rtl::OUString::createFromAscii(" : ")); + } + + return m_pImpl->m_xNumberedControllers; +} +// ----------------------------------------------------------------------------- +// css.frame.XTitle +::rtl::OUString SAL_CALL OReportDefinition::getTitle() + throw (uno::RuntimeException) +{ + // SYNCHRONIZED -> + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + return impl_getTitleHelper_throw()->getTitle (); +} +// ----------------------------------------------------------------------------- +// css.frame.XTitle +void SAL_CALL OReportDefinition::setTitle( const ::rtl::OUString& sTitle ) + throw (uno::RuntimeException) +{ + // SYNCHRONIZED -> + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + impl_getTitleHelper_throw()->setTitle (sTitle); +} +// ----------------------------------------------------------------------------- +// css.frame.XTitleChangeBroadcaster +void SAL_CALL OReportDefinition::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener ) + throw (uno::RuntimeException) +{ + // SYNCHRONIZED -> + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY); + if (xBroadcaster.is ()) + xBroadcaster->addTitleChangeListener (xListener); +} +// ----------------------------------------------------------------------------- +// css.frame.XTitleChangeBroadcaster +void SAL_CALL OReportDefinition::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener ) + throw (uno::RuntimeException) +{ + // SYNCHRONIZED -> + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY); + if (xBroadcaster.is ()) + xBroadcaster->removeTitleChangeListener (xListener); +} +// ----------------------------------------------------------------------------- +// css.frame.XUntitledNumbers +::sal_Int32 SAL_CALL OReportDefinition::leaseNumber( const uno::Reference< uno::XInterface >& xComponent ) + throw (lang::IllegalArgumentException, + uno::RuntimeException ) +{ + // object already disposed? + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + return impl_getUntitledHelper_throw()->leaseNumber (xComponent); +} +// ----------------------------------------------------------------------------- +// css.frame.XUntitledNumbers +void SAL_CALL OReportDefinition::releaseNumber( ::sal_Int32 nNumber ) + throw (lang::IllegalArgumentException, + uno::RuntimeException ) +{ + // object already disposed? + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + impl_getUntitledHelper_throw()->releaseNumber (nNumber); +} +// ----------------------------------------------------------------------------- +// css.frame.XUntitledNumbers +void SAL_CALL OReportDefinition::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent ) + throw (lang::IllegalArgumentException, + uno::RuntimeException ) +{ + // object already disposed? + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent); +} +// ----------------------------------------------------------------------------- +// css.frame.XUntitledNumbers +::rtl::OUString SAL_CALL OReportDefinition::getUntitledPrefix() + throw (uno::RuntimeException) +{ + // object already disposed? + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + + return impl_getUntitledHelper_throw()->getUntitledPrefix (); +} +// ----------------------------------------------------------------------------- +uno::Reference< document::XDocumentProperties > SAL_CALL OReportDefinition::getDocumentProperties( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); + if ( !m_pImpl->m_xDocumentProperties.is() ) + { + uno::Reference< lang::XInitialization > xDocProps( + m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.DocumentProperties")) ,m_aProps->m_xContext), + uno::UNO_QUERY_THROW); + m_pImpl->m_xDocumentProperties.set(xDocProps, uno::UNO_QUERY_THROW); + } + return m_pImpl->m_xDocumentProperties; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XComponentContext > OReportDefinition::getContext() const +{ + return m_aProps->m_xContext; +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OReportDefinition::getTransferData( const datatransfer::DataFlavor& aFlavor ) throw (datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException) +{ + uno::Any aResult; + if( isDataFlavorSupported( aFlavor ) ) + { + try + { + aResult <<= getPreferredVisualRepresentation(0).Data; + } + catch( uno::Exception & ex ) + { + DBG_UNHANDLED_EXCEPTION(); + (void)ex; + } + } + else + { + throw datatransfer::UnsupportedFlavorException(aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this )); + } + + return aResult; +} +// ----------------------------------------------------------------------------- +uno::Sequence< datatransfer::DataFlavor > SAL_CALL OReportDefinition::getTransferDataFlavors( ) throw (uno::RuntimeException) +{ + uno::Sequence< datatransfer::DataFlavor > aRet(1); + + aRet[0] = datatransfer::DataFlavor( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/png")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PNG")), + ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) ); + + return aRet; +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor ) throw (uno::RuntimeException) +{ + return aFlavor.MimeType.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/png"))); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// ============================================================================= +}// namespace reportdesign +// ============================================================================= + diff --git a/reportdesign/source/core/api/ReportEngineJFree.cxx b/reportdesign/source/core/api/ReportEngineJFree.cxx new file mode 100644 index 000000000000..0a39b12455a5 --- /dev/null +++ b/reportdesign/source/core/api/ReportEngineJFree.cxx @@ -0,0 +1,426 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include <com/sun/star/beans/PropertyValue.hpp> +#include "ReportEngineJFree.hxx" +#include <comphelper/enumhelper.hxx> +#include <comphelper/documentconstants.hxx> +#include <comphelper/storagehelper.hxx> +#include <connectivity/dbtools.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/mimeconfighelper.hxx> +#include <comphelper/property.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/sdb/XCompletedExecution.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdb/CommandType.hpp> + +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/task/XJob.hpp> + +#include <tools/debug.hxx> +#include <tools/urlobj.hxx> +#include <unotools/useroptions.hxx> +#include <unotools/tempfile.hxx> +#include <unotools/sharedunocomponent.hxx> + +#include "Tools.hxx" +#include "corestrings.hrc" +#include "core_resource.hrc" +#include "core_resource.hxx" + +#include <connectivity/CommonTools.hxx> +#include <rtl/ustrbuf.hxx> +#include <sfx2/docfilt.hxx> +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; + +DBG_NAME( rpt_OReportEngineJFree ) +// ----------------------------------------------------------------------------- +OReportEngineJFree::OReportEngineJFree( const uno::Reference< uno::XComponentContext >& context) +:ReportEngineBase(m_aMutex) +,ReportEnginePropertySet(context,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) +,m_xContext(context) +,m_nMaxRows(0) +{ + DBG_CTOR( rpt_OReportEngineJFree,NULL); +} +// ----------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +OReportEngineJFree::~OReportEngineJFree() +{ + DBG_DTOR( rpt_OReportEngineJFree,NULL); +} +//-------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2(OReportEngineJFree,ReportEngineBase,ReportEnginePropertySet) +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::dispose() throw(uno::RuntimeException) +{ + ReportEnginePropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); + m_xActiveConnection.clear(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OReportEngineJFree::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OReportEngineJFree")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportEngineJFree::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OReportEngineJFree::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_REPORTENGINE; + + return aServices; +} +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OReportEngineJFree::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OReportEngineJFree(xContext)); +} + +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OReportEngineJFree::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OReportEngineJFree::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +// XReportEngine + // Attributes +uno::Reference< report::XReportDefinition > SAL_CALL OReportEngineJFree::getReportDefinition() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_xReport; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::setReportDefinition( const uno::Reference< report::XReportDefinition >& _report ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + if ( !_report.is() ) + throw lang::IllegalArgumentException(); + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_xReport != _report ) + { + prepareSet(PROPERTY_REPORTDEFINITION, uno::makeAny(m_xReport), uno::makeAny(_report), &l); + m_xReport = _report; + } + } + l.notify(); +} +// ----------------------------------------------------------------------------- +uno::Reference< task::XStatusIndicator > SAL_CALL OReportEngineJFree::getStatusIndicator() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_StatusIndicator; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::setStatusIndicator( const uno::Reference< task::XStatusIndicator >& _statusindicator ) throw (uno::RuntimeException) +{ + set(PROPERTY_STATUSINDICATOR,_statusindicator,m_StatusIndicator); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OReportEngineJFree::getNewOutputName() +{ + ::rtl::OUString sOutputName; + { + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed); + if ( !m_xReport.is() || !m_xActiveConnection.is() ) + throw lang::IllegalArgumentException(); + + static const ::rtl::OUString s_sMediaType(RTL_CONSTASCII_USTRINGPARAM("MediaType")); + try + { + const uno::Reference< lang::XMultiServiceFactory > xFactory(m_xContext->getServiceManager(),uno::UNO_QUERY_THROW); + MimeConfigurationHelper aConfighelper(xFactory); + const ::rtl::OUString sMimeType = m_xReport->getMimeType(); + const SfxFilter* pFilter = SfxFilter::GetDefaultFilter( aConfighelper.GetDocServiceNameFromMediaType(sMimeType) ); + String sExt; + if ( pFilter ) + { + sExt = pFilter->GetDefaultExtension(); + sExt.EraseLeadingChars( '*' ); + } + else + sExt = String::CreateFromAscii(".rpt"); + + uno::Reference< embed::XStorage > xTemp = OStorageHelper::GetTemporaryStorage(/*sFileTemp,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,*/uno::Reference< lang::XMultiServiceFactory >(m_xContext->getServiceManager(),uno::UNO_QUERY)); + utl::DisposableComponent aTemp(xTemp); + uno::Sequence< beans::PropertyValue > aEmpty; + uno::Reference< beans::XPropertySet> xStorageProp(xTemp,uno::UNO_QUERY); + if ( xStorageProp.is() ) + { + xStorageProp->setPropertyValue( s_sMediaType, uno::makeAny(sMimeType)); + } + m_xReport->storeToStorage(xTemp,aEmpty); // store to temp file because it may contain information which aren't in the database yet. + + uno::Sequence< beans::NamedValue > aConvertedProperties(8); + sal_Int32 nPos = 0; + aConvertedProperties[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStorage")); + aConvertedProperties[nPos++].Value <<= xTemp; + aConvertedProperties[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputStorage")); + + ::rtl::OUString sFileURL; + String sName = m_xReport->getCaption(); + if ( !sName.Len() ) + sName = m_xReport->getName(); + { + ::utl::TempFile aTestFile(sName,sal_False,&sExt); + if ( !aTestFile.IsValid() ) + { + sName = RPT_RESSTRING(RID_STR_REPORT,m_xContext->getServiceManager()); + ::utl::TempFile aFile(sName,sal_False,&sExt); + sFileURL = aFile.GetURL(); + } + else + sFileURL = aTestFile.GetURL(); + } + + uno::Reference< embed::XStorage > xOut = OStorageHelper::GetStorageFromURL(sFileURL,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,uno::Reference< lang::XMultiServiceFactory >(m_xContext->getServiceManager(),uno::UNO_QUERY)); + utl::DisposableComponent aOut(xOut); + xStorageProp.set(xOut,uno::UNO_QUERY); + if ( xStorageProp.is() ) + { + xStorageProp->setPropertyValue( s_sMediaType, uno::makeAny(sMimeType)); + } + + aConvertedProperties[nPos++].Value <<= xOut; + + aConvertedProperties[nPos].Name = PROPERTY_REPORTDEFINITION; + aConvertedProperties[nPos++].Value <<= m_xReport; + + aConvertedProperties[nPos].Name = PROPERTY_ACTIVECONNECTION; + aConvertedProperties[nPos++].Value <<= m_xActiveConnection; + + aConvertedProperties[nPos].Name = PROPERTY_MAXROWS; + aConvertedProperties[nPos++].Value <<= m_nMaxRows; + + // some meta data + SvtUserOptions aUserOpts; + ::rtl::OUStringBuffer sAuthor(aUserOpts.GetFirstName()); + sAuthor.appendAscii(" "); + sAuthor.append(aUserOpts.GetLastName()); + static const ::rtl::OUString s_sAuthor(RTL_CONSTASCII_USTRINGPARAM("Author")); + aConvertedProperties[nPos].Name = s_sAuthor; + aConvertedProperties[nPos++].Value <<= sAuthor.makeStringAndClear(); + + static const ::rtl::OUString s_sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")); + aConvertedProperties[nPos].Name = s_sTitle; + aConvertedProperties[nPos++].Value <<= m_xReport->getCaption(); + + // create job factory and initialize + const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(xFactory); + uno::Reference<task::XJob> xJob(m_xContext->getServiceManager()->createInstanceWithContext(sReportEngineServiceName,m_xContext),uno::UNO_QUERY_THROW); + if ( m_xReport->getCommand().getLength() ) + { + xJob->execute(aConvertedProperties); + if ( xStorageProp.is() ) + { + //xStorageProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"))) >>= sOutputName; + sOutputName = sFileURL; + } + } + + uno::Reference<embed::XTransactedObject> xTransact(xOut,uno::UNO_QUERY); + if ( sOutputName.getLength() && xTransact.is() ) + xTransact->commit(); + + if ( !sOutputName.getLength() ) + throw lang::IllegalArgumentException(); + } + catch(const uno::Exception& e) + { + (void)e; // helper to know what e contains + throw; + } + } + return sOutputName; +} +// ----------------------------------------------------------------------------- +// Methods +uno::Reference< frame::XModel > SAL_CALL OReportEngineJFree::createDocumentModel( ) throw (lang::DisposedException, lang::IllegalArgumentException, uno::Exception, uno::RuntimeException) +{ + return createDocumentAlive(NULL,true); +} +// ----------------------------------------------------------------------------- +uno::Reference< frame::XModel > SAL_CALL OReportEngineJFree::createDocumentAlive( const uno::Reference< frame::XFrame >& _frame ) throw (lang::DisposedException, lang::IllegalArgumentException, uno::Exception, uno::RuntimeException) +{ + return createDocumentAlive(_frame,false); +} +// ----------------------------------------------------------------------------- +uno::Reference< frame::XModel > SAL_CALL OReportEngineJFree::createDocumentAlive( const uno::Reference< frame::XFrame >& _frame,bool _bHidden ) throw (lang::DisposedException, lang::IllegalArgumentException, uno::Exception, uno::RuntimeException) +{ + uno::Reference< frame::XModel > xModel; + ::rtl::OUString sOutputName = getNewOutputName(); // starts implicite the report generator + if ( sOutputName.getLength() ) + { + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed); + uno::Reference<frame::XComponentLoader> xFrameLoad(_frame,uno::UNO_QUERY); + if ( !xFrameLoad.is() ) + { + // if there is no frame given, find the right + xFrameLoad.set( m_xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) + ,m_xContext) + ,uno::UNO_QUERY); + ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank")); + sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE; + uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY)->findFrame(sTarget,nFrameSearchFlag); + xFrameLoad.set( xFrame,uno::UNO_QUERY); + } + + if ( xFrameLoad.is() ) + { + uno::Sequence < beans::PropertyValue > aArgs( _bHidden ? 3 : 2 ); + sal_Int32 nLen = 0; + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate")); + aArgs[nLen++].Value <<= sal_False; + + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")); + aArgs[nLen++].Value <<= sal_True; + + if ( _bHidden ) + { + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden")); + aArgs[nLen++].Value <<= sal_True; + } + + uno::Reference< lang::XMultiServiceFactory > xFac(m_xContext->getServiceManager(),uno::UNO_QUERY); + /*::comphelper::MimeConfigurationHelper aHelper(xFac);*/ + xModel.set( xFrameLoad->loadComponentFromURL( + sOutputName, + ::rtl::OUString(), // empty frame name + 0, + aArgs + ),uno::UNO_QUERY); + } + } + return xModel; +} +// ----------------------------------------------------------------------------- +util::URL SAL_CALL OReportEngineJFree::createDocument( ) throw (lang::DisposedException, lang::IllegalArgumentException, uno::Exception, uno::RuntimeException) +{ + util::URL aRet; + uno::Reference< frame::XModel > xModel = createDocumentModel(); + if ( xModel.is() ) + { + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed); + } + return aRet; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::interrupt( ) throw (lang::DisposedException, uno::Exception, uno::RuntimeException) +{ + { + ::osl::MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed); + } +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OReportEngineJFree::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return ReportEnginePropertySet::getPropertySetInfo(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportEnginePropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OReportEngineJFree::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return ReportEnginePropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportEnginePropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportEnginePropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportEnginePropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ReportEnginePropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +uno::Reference< sdbc::XConnection > SAL_CALL OReportEngineJFree::getActiveConnection() throw (uno::RuntimeException) +{ + return m_xActiveConnection; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::setActiveConnection( const uno::Reference< sdbc::XConnection >& _activeconnection ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + if ( !_activeconnection.is() ) + throw lang::IllegalArgumentException(); + set(PROPERTY_ACTIVECONNECTION,_activeconnection,m_xActiveConnection); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OReportEngineJFree::getMaxRows() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_nMaxRows; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportEngineJFree::setMaxRows( ::sal_Int32 _MaxRows ) throw (uno::RuntimeException) +{ + set(PROPERTY_MAXROWS,_MaxRows,m_nMaxRows); +} +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/ReportVisitor.cxx b/reportdesign/source/core/api/ReportVisitor.cxx new file mode 100644 index 000000000000..ea1ef11b239f --- /dev/null +++ b/reportdesign/source/core/api/ReportVisitor.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ReportVisitor.hxx" +namespace reportdesign +{ +using namespace com::sun::star; + +OReportVisitor::OReportVisitor(ITraverseReport* _pTraverseReport) + :m_pTraverseReport(_pTraverseReport) +{ + OSL_ENSURE(m_pTraverseReport,"ReportDefintion must be not NULL!"); +} +// ----------------------------------------------------------------------------- +void OReportVisitor::start(const uno::Reference< report::XReportDefinition>& _xReportDefinition) +{ + OSL_ENSURE(_xReportDefinition.is(),"ReportDefinition is NULL!"); + if ( !_xReportDefinition.is() ) + return; + + m_pTraverseReport->traverseReport(_xReportDefinition); + m_pTraverseReport->traverseReportFunctions(_xReportDefinition->getFunctions()); + if ( _xReportDefinition->getPageHeaderOn() ) + m_pTraverseReport->traversePageHeader(_xReportDefinition->getPageHeader()); + if ( _xReportDefinition->getReportHeaderOn() ) + m_pTraverseReport->traverseReportHeader(_xReportDefinition->getReportHeader()); + + uno::Reference< report::XGroups > xGroups = _xReportDefinition->getGroups(); + m_pTraverseReport->traverseGroups(xGroups); + const sal_Int32 nCount = xGroups->getCount(); + sal_Int32 i = 0; + for (;i<nCount ; ++i) + { + uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY); + m_pTraverseReport->traverseGroup(xGroup); + m_pTraverseReport->traverseGroupFunctions(xGroup->getFunctions()); + if ( xGroup->getHeaderOn() ) + m_pTraverseReport->traverseGroupHeader(xGroup->getHeader()); + } + + m_pTraverseReport->traverseDetail(_xReportDefinition->getDetail()); + + for (i = 0;i<nCount ; ++i) + { + uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY); + if ( xGroup->getFooterOn() ) + m_pTraverseReport->traverseGroupFooter(xGroup->getFooter()); + } + + if ( _xReportDefinition->getPageFooterOn() ) + m_pTraverseReport->traversePageFooter(_xReportDefinition->getPageFooter()); + if ( _xReportDefinition->getReportFooterOn() ) + m_pTraverseReport->traverseReportFooter(_xReportDefinition->getReportFooter()); +} +// ----------------------------------------------------------------------------- +void OReportVisitor::start(const uno::Reference< report::XGroup>& _xGroup) +{ + OSL_ENSURE(_xGroup.is(),"Group is NULL!"); + if ( !_xGroup.is() ) + return; + m_pTraverseReport->traverseGroup(_xGroup); + m_pTraverseReport->traverseGroupFunctions(_xGroup->getFunctions()); + if ( _xGroup->getHeaderOn() ) + m_pTraverseReport->traverseGroupHeader(_xGroup->getHeader()); + if ( _xGroup->getFooterOn() ) + m_pTraverseReport->traverseGroupFooter(_xGroup->getFooter()); +} +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx new file mode 100644 index 000000000000..65040676e6d6 --- /dev/null +++ b/reportdesign/source/core/api/Section.cxx @@ -0,0 +1,723 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Section.hxx" +#include <comphelper/enumhelper.hxx> +#include <connectivity/dbtools.hxx> +#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> +#ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC +#include "corestrings.hrc" +#endif +#include "core_resource.hxx" +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include <tools/debug.hxx> +#include "Tools.hxx" +#include "RptModel.hxx" +#include "RptPage.hxx" +#include "ReportDefinition.hxx" +#include "Shape.hxx" +#include <svx/unoshape.hxx> +#include "RptObject.hxx" +#include "ReportDrawPage.hxx" +#include <comphelper/property.hxx> +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +DBG_NAME( rpt_OSection ) +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString> lcl_getGroupAbsent() +{ + ::rtl::OUString pProps[] = { + PROPERTY_CANGROW + ,PROPERTY_CANSHRINK + }; + + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} + +// ----------------------------------------------------------------------------- +OSection::OSection( const uno::Reference< report::XGroup >& _xParent + ,const uno::Reference< uno::XComponentContext >& context + ,bool /*_bPageSection*/) +:SectionBase(m_aMutex) +,SectionPropertySet(context,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getGroupAbsent()) +,m_aContainerListeners(m_aMutex) +,m_xContext(context) +,m_xGroup(_xParent) +,m_nHeight(3000) +,m_nBackgroundColor(COL_TRANSPARENT) +,m_nForceNewPage(report::ForceNewPage::NONE) +,m_nNewRowOrCol(report::ForceNewPage::NONE) +,m_bKeepTogether(sal_False) +,m_bCanGrow(sal_False) +,m_bCanShrink(sal_False) +,m_bRepeatSection(sal_False) +,m_bVisible(sal_True) +,m_bBacktransparent(sal_True) +,m_bInRemoveNotify(false) +,m_bInInsertNotify(false) +{ + DBG_CTOR( rpt_OSection,NULL); + init(); +} +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString> lcl_getAbsent(bool _bPageSection) +{ + if ( _bPageSection ) + { + ::rtl::OUString pProps[] = { + PROPERTY_FORCENEWPAGE + ,PROPERTY_NEWROWORCOL + ,PROPERTY_KEEPTOGETHER + ,PROPERTY_CANGROW + ,PROPERTY_CANSHRINK + ,PROPERTY_REPEATSECTION + }; + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + } + + ::rtl::OUString pProps[] = { + PROPERTY_CANGROW + ,PROPERTY_CANSHRINK + ,PROPERTY_REPEATSECTION + }; + + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} +// ----------------------------------------------------------------------------- +OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent + ,const uno::Reference< uno::XComponentContext >& context + ,bool _bPageSection) +:SectionBase(m_aMutex) +,SectionPropertySet(context,SectionPropertySet::IMPLEMENTS_PROPERTY_SET,lcl_getAbsent(_bPageSection)) +,m_aContainerListeners(m_aMutex) +,m_xContext(context) +,m_xReportDefinition(_xParent) +,m_nHeight(3000) +,m_nBackgroundColor(COL_TRANSPARENT) +,m_nForceNewPage(report::ForceNewPage::NONE) +,m_nNewRowOrCol(report::ForceNewPage::NONE) +,m_bKeepTogether(sal_False) +,m_bCanGrow(sal_False) +,m_bCanShrink(sal_False) +,m_bRepeatSection(sal_False) +,m_bVisible(sal_True) +,m_bBacktransparent(sal_True) +,m_bInRemoveNotify(false) +,m_bInInsertNotify(false) +{ + DBG_CTOR( rpt_OSection,NULL); + init(); + //.getSdrModel()->createNewPage(m_xSection); +} +//-------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +OSection::~OSection() +{ + DBG_DTOR( rpt_OSection,NULL); + if ( m_xProxy.is() ) + m_xProxy->setDelegator( NULL ); +} +//-------------------------------------------------------------------------- +//IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet) +IMPLEMENT_FORWARD_REFCOUNT( OSection, SectionBase ) +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = SectionBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = SectionPropertySet::queryInterface(_rType); + + if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) + return aReturn; + + return aReturn.hasValue() ? aReturn : (m_xProxy.is() ? m_xProxy->queryAggregation(_rType) : aReturn); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::dispose() throw(uno::RuntimeException) +{ + OSL_ENSURE(!rBHelper.bDisposed,"Already disposed!"); + SectionPropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); + +} +// ----------------------------------------------------------------------------- +// TODO: VirtualFunctionFinder: This is virtual function! +// +void SAL_CALL OSection::disposing() +{ + lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aContainerListeners.disposeAndClear( aDisposeEvent ); + m_xContext.clear(); + //m_xDrawPage.clear(); + + /*uno::Reference< report::XReportDefinition> xReport = getReportDefinition(); + ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport); + osl_incrementInterlockedCount( &m_refCount ); + while( m_xDrawPage.is() && m_xDrawPage->hasElements() ) + { + try + { + uno::Reference< drawing::XShape> xShape(m_xDrawPage->getByIndex(0),uno::UNO_QUERY); + m_xDrawPage->remove(xShape); + ::comphelper::disposeComponent(xShape); + } + catch(const uno::Exception&) + {} + } + if ( pModel ) + { + uno::Reference< report::XSection> xSection = this; + pModel->DeletePage(pModel->getPage(xSection)->GetPageNum()); + } + osl_decrementInterlockedCount( &m_refCount );*/ +} +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OSection::getImplementationName( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Section")); +} +//------------------------------------------------------------------------------ +uno::Sequence< ::rtl::OUString> OSection::getSupportedServiceNames_Static(void) throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString> aSupported(1); + aSupported.getArray()[0] = SERVICE_SECTION; + return aSupported; +} +//------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString> SAL_CALL OSection::getSupportedServiceNames() throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OSection::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException) +{ + return ::comphelper::existsValue(_rServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +void OSection::init() +{ + uno::Reference< report::XReportDefinition> xReport = getReportDefinition(); + ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport); + OSL_ENSURE(pModel,"No odel set at the report definition!"); + if ( pModel ) + { +// DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86 + osl_incrementInterlockedCount( &m_refCount ); + { + uno::Reference<report::XSection> xTemp = this; + { + { + m_xProxy.set(pModel->createNewPage(xTemp)->getUnoPage(),uno::UNO_QUERY); + } + { + ::comphelper::query_aggregation(m_xProxy,m_xDrawPage); + } + + // set ourself as delegator + { + if ( m_xProxy.is() ) + { + m_xProxy->setDelegator( xTemp ); + } + } + } + xTemp.clear(); + } +// DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86 + osl_decrementInterlockedCount( &m_refCount ); + } +} +// ----------------------------------------------------------------------------- +// XSection +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::getVisible() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_bVisible; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException) +{ + set(PROPERTY_VISIBLE,_visible,m_bVisible); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OSection::getName() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_sName; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException) +{ + set(PROPERTY_NAME,_name,m_sName); +} +// ----------------------------------------------------------------------------- +::sal_uInt32 SAL_CALL OSection::getHeight() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_nHeight; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setHeight( ::sal_uInt32 _height ) throw (uno::RuntimeException) +{ + set(PROPERTY_HEIGHT,_height,m_nHeight); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OSection::getBackColor() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_bBacktransparent ? COL_TRANSPARENT : m_nBackgroundColor; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setBackColor( ::sal_Int32 _backgroundcolor ) throw (uno::RuntimeException) +{ + sal_Bool bTransparent = _backgroundcolor == static_cast<sal_Int32>(COL_TRANSPARENT); + setBackTransparent(bTransparent); + if ( !bTransparent ) + set(PROPERTY_BACKCOLOR,_backgroundcolor,m_nBackgroundColor); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::getBackTransparent() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_bBacktransparent; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setBackTransparent( ::sal_Bool _backtransparent ) throw (uno::RuntimeException) +{ + set(PROPERTY_BACKTRANSPARENT,_backtransparent,m_bBacktransparent); + if ( _backtransparent ) + set(PROPERTY_BACKCOLOR,static_cast<sal_Int32>(COL_TRANSPARENT),m_nBackgroundColor); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OSection::getConditionalPrintExpression() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_sConditionalPrintExpression; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (uno::RuntimeException) +{ + set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_sConditionalPrintExpression); +} +// ----------------------------------------------------------------------------- +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) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + checkNotPageHeaderFooter(); + return m_nForceNewPage; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setForceNewPage( ::sal_Int16 _forcenewpage ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + if ( _forcenewpage < report::ForceNewPage::NONE || _forcenewpage > report::ForceNewPage::BEFORE_AFTER_SECTION ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage")) + ,*this + ,1 + ,m_xContext); + checkNotPageHeaderFooter(); + set(PROPERTY_FORCENEWPAGE,_forcenewpage,m_nForceNewPage); +} +// ----------------------------------------------------------------------------- +::sal_Int16 SAL_CALL OSection::getNewRowOrCol() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkNotPageHeaderFooter(); + return m_nNewRowOrCol; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setNewRowOrCol( ::sal_Int16 _newroworcol ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + if ( _newroworcol < report::ForceNewPage::NONE || _newroworcol > report::ForceNewPage::BEFORE_AFTER_SECTION ) + throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage")) + ,*this + ,1 + ,m_xContext); + checkNotPageHeaderFooter(); + + set(PROPERTY_NEWROWORCOL,_newroworcol,m_nNewRowOrCol); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::getKeepTogether() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkNotPageHeaderFooter(); + return m_bKeepTogether; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setKeepTogether( ::sal_Bool _keeptogether ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + { + ::osl::MutexGuard aGuard(m_aMutex); + checkNotPageHeaderFooter(); + } + + set(PROPERTY_KEEPTOGETHER,_keeptogether,m_bKeepTogether); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::getCanGrow() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setCanGrow( ::sal_Bool /*_cangrow*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::getCanShrink() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::setCanShrink( ::sal_Bool /*_canshrink*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::getRepeatSection() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::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) +{ + { + ::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) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_xGroup; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XReportDefinition > SAL_CALL OSection::getReportDefinition() throw (uno::RuntimeException) +{ + ::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()); + if ( xGroups.is() ) + xRet = xGroups->getReportDefinition(); + } + + return xRet; +} +// ----------------------------------------------------------------------------- +const ::std::vector< ::rtl::OUString >& lcl_getControlModelMap() +{ + static ::std::vector< ::rtl::OUString > s_sControlModels; + if ( s_sControlModels.empty() ) + { + s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedText")) ); + s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedLine")) ); + s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageControl")) ); + s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormattedField")) ); + s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shape")) ); + } // if ( s_sMap.empty() ) + return s_sControlModels; + +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XReportComponent > SAL_CALL OSection::createReportComponent( const ::rtl::OUString& _sReportComponentSpecifier ) throw (uno::Exception, lang::IllegalArgumentException,uno::RuntimeException) +{ + ::osl::ResettableMutexGuard aGuard(m_aMutex); + const ::std::vector< ::rtl::OUString >& aRet = lcl_getControlModelMap(); + ::std::vector< ::rtl::OUString >::const_iterator aFind = ::std::find(aRet.begin(),aRet.end(),_sReportComponentSpecifier); + if ( aFind == aRet.end() ) + throw lang::IllegalArgumentException(); + + uno::Reference< report::XReportComponent > xRet; + uno::Reference< lang::XMultiServiceFactory> xFac(getReportDefinition(),uno::UNO_QUERY_THROW); + switch( aFind - aRet.begin() ) + { + case 0: + xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))),uno::UNO_QUERY); + break; + case 1: + xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))),uno::UNO_QUERY); + break; + case 2: + xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))),uno::UNO_QUERY); + break; + case 3: + xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))),uno::UNO_QUERY); + break; + case 4: + xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape"))),uno::UNO_QUERY); + break; + default: + //xRet = new OShape(m_xContext); + break; + } // switch( aRet.begin() - aFind ) + return xRet; +} +// ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OSection::getAvailableReportComponentNames( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + const ::std::vector< ::rtl::OUString >& aRet = lcl_getControlModelMap(); + const ::rtl::OUString* pRet = aRet.empty() ? 0 : &aRet[0]; + return uno::Sequence< ::rtl::OUString >(pRet, aRet.size()); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OSection::getParent( ) throw (uno::RuntimeException) +{ + 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) +{ + throw lang::NoSupportException(); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OSection::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aContainerListeners.addInterface(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aContainerListeners.removeInterface(xListener); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OSection::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XReportComponent>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OSection::hasElements( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_xDrawPage.is() ? m_xDrawPage->hasElements() : sal_False; +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OSection::getCount( ) throw (uno::RuntimeException) +{ + ::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) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_xDrawPage->getByIndex(Index); +} +// ----------------------------------------------------------------------------- +// XEnumerationAccess +uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this)); +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OSection::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + return SectionPropertySet::getPropertySetInfo(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OSection::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + SectionPropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OSection::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return SectionPropertySet::getPropertyValue( PropertyName); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + SectionPropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + SectionPropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + SectionPropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OSection::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + SectionPropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +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) +{ + { + ::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) +{ + { + ::osl::MutexGuard aGuard(m_aMutex); + m_bInRemoveNotify = true; + OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!"); + m_xDrawPage->remove(xShape); + m_bInRemoveNotify = false; + } + notifyElementRemoved(xShape); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OSection::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw (uno::RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return reinterpret_cast<sal_Int64>(this); + uno::Reference< lang::XUnoTunnel> xTunnel; + ::comphelper::query_aggregation(m_xProxy,xTunnel); + return xTunnel->getSomething(rId); +} + +// ----------------------------------------------------------------------------- +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; +} +//------------------------------------------------------------------------ +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(); +} +// ----------------------------------------------------------------------------- +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); + } +} +// ----------------------------------------------------------------------------- +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); + } +} +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/Shape.cxx b/reportdesign/source/core/api/Shape.cxx new file mode 100644 index 000000000000..5b1baf53f5f8 --- /dev/null +++ b/reportdesign/source/core/api/Shape.cxx @@ -0,0 +1,522 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Shape.hxx" + +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/text/ParagraphVertAlign.hpp> +#include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <boost/bind.hpp> +#include <svx/unoshape.hxx> + +#include "corestrings.hrc" +#include "core_resource.hrc" +#include "core_resource.hxx" +#include "Tools.hxx" +#include "RptObject.hxx" +#include "FormatCondition.hxx" +#include "ReportHelperImpl.hxx" +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= + using namespace com::sun::star; + using namespace comphelper; +uno::Sequence< ::rtl::OUString > lcl_getShapeOptionals() +{ + ::rtl::OUString pProps[] = { + PROPERTY_DATAFIELD + ,PROPERTY_CONTROLBACKGROUND + ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT + }; + return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); +} + +DBG_NAME( rpt_OShape ) +// ----------------------------------------------------------------------------- +OShape::OShape(uno::Reference< uno::XComponentContext > const & _xContext) +:ShapeBase(m_aMutex) +,ShapePropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getShapeOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nZOrder(0) +,m_bOpaque(sal_False) +{ + DBG_CTOR( rpt_OShape,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_SHAPE,m_aProps.aComponent.m_xContext->getServiceManager()); +} +// ----------------------------------------------------------------------------- +OShape::OShape(uno::Reference< uno::XComponentContext > const & _xContext + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,uno::Reference< drawing::XShape >& _xShape + ,const ::rtl::OUString& _sServiceName) +:ShapeBase(m_aMutex) +,ShapePropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getShapeOptionals()) +,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext) +,m_nZOrder(0) +,m_bOpaque(sal_False) +,m_sServiceName(_sServiceName) +{ + DBG_CTOR( rpt_OShape,NULL); + m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_SHAPE,m_aProps.aComponent.m_xContext->getServiceManager()); + m_aProps.aComponent.m_xFactory = _xFactory; + osl_incrementInterlockedCount( &m_refCount ); + { + uno::Reference<beans::XPropertySet> xProp(_xShape,uno::UNO_QUERY); + if ( xProp.is() ) + { + xProp->getPropertyValue(PROPERTY_ZORDER) >>= m_nZOrder; + xProp.clear(); + } + m_aProps.aComponent.setShape(_xShape,this,m_refCount); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// ----------------------------------------------------------------------------- +OShape::~OShape() +{ + DBG_DTOR( rpt_OShape,NULL); +} +// ----------------------------------------------------------------------------- +//IMPLEMENT_FORWARD_XINTERFACE2(OShape,ShapeBase,ShapePropertySet) +IMPLEMENT_FORWARD_REFCOUNT( OShape, ShapeBase ) +// -------------------------------------------------------------------------------- +uno::Any SAL_CALL OShape::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +{ + uno::Any aReturn = ShapeBase::queryInterface(_rType); + if ( !aReturn.hasValue() ) + aReturn = ShapePropertySet::queryInterface(_rType); + + if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) + return aReturn; + + return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::dispose() throw(uno::RuntimeException) +{ + ShapePropertySet::dispose(); + cppu::WeakComponentImplHelperBase::dispose(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OShape::getImplementationName_Static( ) throw(uno::RuntimeException) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Shape")); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OShape::getImplementationName( ) throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > OShape::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aServices(1); + aServices.getArray()[0] = SERVICE_SHAPE; + + return aServices; +} +//------------------------------------------------------------------------------ +uno::Reference< uno::XInterface > OShape::create(uno::Reference< uno::XComponentContext > const & xContext) +{ + return *(new OShape(xContext)); +} + +//-------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > SAL_CALL OShape::getSupportedServiceNames( ) throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OShape::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) +{ + + return m_sServiceName == ServiceName || ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); +} +// ----------------------------------------------------------------------------- +// XReportComponent +REPORTCOMPONENT_IMPL(OShape,m_aProps.aComponent) +REPORTCOMPONENT_IMPL2(OShape,m_aProps.aComponent) +REPORTCOMPONENT_MASTERDETAIL(OShape,m_aProps.aComponent) +REPORTCONTROLFORMAT_IMPL2(OShape,m_aProps.aFormatProperties) +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OShape::getControlBackground() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setControlBackground( ::sal_Int32 /*_backgroundcolor*/ ) throw (uno::RuntimeException,beans::UnknownPropertyException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OShape::getControlBackgroundTransparent() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setControlBackgroundTransparent( ::sal_Bool /*_controlbackgroundtransparent*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySetInfo > SAL_CALL OShape::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + + //return ShapePropertySet::getPropertySetInfo(); + return cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); +} +// ----------------------------------------------------------------------------- +cppu::IPropertyArrayHelper& OShape::getInfoHelper() +{ + if ( !m_pAggHelper.get() ) + { + uno::Sequence<beans::Property> aAggSeq; + if ( m_aProps.aComponent.m_xProperty.is() ) + aAggSeq = m_aProps.aComponent.m_xProperty->getPropertySetInfo()->getProperties(); + m_pAggHelper.reset(new OPropertyArrayAggregationHelper(ShapePropertySet::getPropertySetInfo()->getProperties(),aAggSeq)); + } + return *(m_pAggHelper.get()); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + getInfoHelper(); + if( m_pAggHelper->classifyProperty(aPropertyName) == OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY ) + m_aProps.aComponent.m_xProperty->setPropertyValue( aPropertyName,aValue); + // can be in both + if( m_pAggHelper->classifyProperty(aPropertyName) == OPropertyArrayAggregationHelper::DELEGATOR_PROPERTY ) + ShapePropertySet::setPropertyValue( aPropertyName, aValue ); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OShape::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + getInfoHelper(); + if( m_pAggHelper->classifyProperty(PropertyName) == OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY ) + return m_aProps.aComponent.m_xProperty->getPropertyValue( PropertyName); + // can be in both + if( m_pAggHelper->classifyProperty(PropertyName) == OPropertyArrayAggregationHelper::DELEGATOR_PROPERTY ) + return ShapePropertySet::getPropertyValue( PropertyName); + return uno::Any(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + getInfoHelper(); + if( m_pAggHelper->classifyProperty(aPropertyName) == OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY || !aPropertyName.getLength() ) + m_aProps.aComponent.m_xProperty->addPropertyChangeListener( aPropertyName, xListener); + // can be in both + if( m_pAggHelper->classifyProperty(aPropertyName) == OPropertyArrayAggregationHelper::DELEGATOR_PROPERTY || !aPropertyName.getLength() ) + ShapePropertySet::addPropertyChangeListener( aPropertyName, xListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + getInfoHelper(); + if( m_pAggHelper->classifyProperty(aPropertyName) == OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY || !aPropertyName.getLength() ) + m_aProps.aComponent.m_xProperty->removePropertyChangeListener( aPropertyName, aListener ); + // can be in both + if( m_pAggHelper->classifyProperty(aPropertyName) == OPropertyArrayAggregationHelper::DELEGATOR_PROPERTY || !aPropertyName.getLength() ) + ShapePropertySet::removePropertyChangeListener( aPropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + getInfoHelper(); + if( m_pAggHelper->classifyProperty(PropertyName) == OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY || !PropertyName.getLength() ) + m_aProps.aComponent.m_xProperty->addVetoableChangeListener( PropertyName, aListener ); + // can be in both + if( m_pAggHelper->classifyProperty(PropertyName) == OPropertyArrayAggregationHelper::DELEGATOR_PROPERTY || !PropertyName.getLength() ) + ShapePropertySet::addVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + getInfoHelper(); + if( m_pAggHelper->classifyProperty(PropertyName) == OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY || !PropertyName.getLength() ) + m_aProps.aComponent.m_xProperty->removeVetoableChangeListener( PropertyName, aListener ); + // can be in both + if( m_pAggHelper->classifyProperty(PropertyName) == OPropertyArrayAggregationHelper::DELEGATOR_PROPERTY || !PropertyName.getLength() ) + ShapePropertySet::removeVetoableChangeListener( PropertyName, aListener ); +} +// ----------------------------------------------------------------------------- +// XReportControlModel +::rtl::OUString SAL_CALL OShape::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setDataField( const ::rtl::OUString& /*_datafield*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) +{ + throw beans::UnknownPropertyException(); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OShape::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.bPrintWhenGroupChange; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OShape::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_aProps.aConditionalPrintExpression; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression); +} +// ----------------------------------------------------------------------------- + +// XCloneable +uno::Reference< util::XCloneable > SAL_CALL OShape::createClone( ) throw (uno::RuntimeException) +{ + uno::Reference< report::XReportComponent> xSource = this; + uno::Reference< report::XReportComponent> xSet; + try + { + SvxShape* pShape = SvxShape::getImplementation( xSource ); + if ( pShape ) + { + SdrObject* pObject = pShape->GetSdrObject(); + if ( pObject ) + { + SdrObject* pClone = pObject->Clone(); + if ( pClone ) + { + xSet.set(pClone->getUnoShape(),uno::UNO_QUERY_THROW ); + + // ::comphelper::copyProperties(xSource.get(),xSet.get()); + } + } + } // if ( pShape ) + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xSet.get(); +} +// ----------------------------------------------------------------------------- +// XChild +uno::Reference< uno::XInterface > SAL_CALL OShape::getParent( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getParent(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xParent = uno::Reference< container::XChild >(Parent,uno::UNO_QUERY); + // not supported by the shape + //uno::Reference< container::XChild > xChild; + //comphelper::query_aggregation(m_aProps.aComponent.m_xProxy,xChild); + //if ( xChild.is() ) + // xChild->setParent(Parent); +} +uno::Reference< report::XFormatCondition > SAL_CALL OShape::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException) +{ + return new OFormatCondition(m_aProps.aComponent.m_xContext); +} +// ----------------------------------------------------------------------------- +// XContainer +void SAL_CALL OShape::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.addContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException) +{ + m_aProps.removeContainerListener(xListener); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL OShape::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OShape::hasElements( ) throw (uno::RuntimeException) +{ + return m_aProps.hasElements(); +} +// ----------------------------------------------------------------------------- +// XIndexContainer +void SAL_CALL OShape::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.insertByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.removeByIndex(Index); +} +// ----------------------------------------------------------------------------- +// XIndexReplace +void SAL_CALL OShape::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aProps.replaceByIndex(Index,Element); +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL OShape::getCount( ) throw (uno::RuntimeException) +{ + return m_aProps.getCount(); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OShape::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_aProps.getByIndex( Index ); +} +// ----------------------------------------------------------------------------- +// XShape +awt::Point SAL_CALL OShape::getPosition( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getPosition(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) +{ + OShapeHelper::setPosition(aPosition,this); +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OShape::getSize( ) throw (uno::RuntimeException) +{ + return OShapeHelper::getSize(this); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) +{ + OShapeHelper::setSize(aSize,this); +} +// ----------------------------------------------------------------------------- + +// XShapeDescriptor +::rtl::OUString SAL_CALL OShape::getShapeType( ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( m_aProps.aComponent.m_xShape.is() ) + return m_aProps.aComponent.m_xShape->getShapeType(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OShape::getZOrder() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xProperty->getPropertyValue(PROPERTY_ZORDER) >>= m_nZOrder; + return m_nZOrder; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setZOrder( ::sal_Int32 _zorder ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xProperty->setPropertyValue(PROPERTY_ZORDER,uno::makeAny(_zorder)); + set(PROPERTY_ZORDER,_zorder,m_nZOrder); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OShape::getOpaque() throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + return m_bOpaque; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setOpaque( ::sal_Bool _opaque ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + set(PROPERTY_OPAQUE,_opaque,m_bOpaque); +} +// ----------------------------------------------------------------------------- +drawing::HomogenMatrix3 SAL_CALL OShape::getTransformation() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xProperty->getPropertyValue(PROPERTY_TRANSFORMATION) >>= m_Transformation; + return m_Transformation; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setTransformation( const drawing::HomogenMatrix3& _transformation ) throw (uno::RuntimeException) +{ + m_aProps.aComponent.m_xProperty->setPropertyValue(PROPERTY_TRANSFORMATION,uno::makeAny(_transformation)); + set(PROPERTY_TRANSFORMATION,_transformation,m_Transformation); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OShape::getCustomShapeEngine() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xProperty->getPropertyValue(PROPERTY_CUSTOMSHAPEENGINE) >>= m_CustomShapeEngine; + + return m_CustomShapeEngine; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setCustomShapeEngine( const ::rtl::OUString& _customshapeengine ) throw (uno::RuntimeException) +{ + m_aProps.aComponent.m_xProperty->setPropertyValue(PROPERTY_CUSTOMSHAPEENGINE,uno::makeAny(_customshapeengine)); + set(PROPERTY_CUSTOMSHAPEENGINE,_customshapeengine,m_CustomShapeEngine); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OShape::getCustomShapeData() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xProperty->getPropertyValue(PROPERTY_CUSTOMSHAPEDATA) >>= m_CustomShapeData; + return m_CustomShapeData; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setCustomShapeData( const ::rtl::OUString& _customshapedata ) throw (uno::RuntimeException) +{ + m_aProps.aComponent.m_xProperty->setPropertyValue(PROPERTY_CUSTOMSHAPEDATA,uno::makeAny(_customshapedata)); + set(PROPERTY_CUSTOMSHAPEDATA,_customshapedata,m_CustomShapeData); +} +// ----------------------------------------------------------------------------- +uno::Sequence< beans::PropertyValue > SAL_CALL OShape::getCustomShapeGeometry() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + m_aProps.aComponent.m_xProperty->getPropertyValue(PROPERTY_CUSTOMSHAPEGEOMETRY) >>= m_CustomShapeGeometry; + return m_CustomShapeGeometry; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OShape::setCustomShapeGeometry( const uno::Sequence< beans::PropertyValue >& _customshapegeometry ) throw (uno::RuntimeException) +{ + m_aProps.aComponent.m_xProperty->setPropertyValue(PROPERTY_CUSTOMSHAPEGEOMETRY,uno::makeAny(_customshapegeometry)); + set(PROPERTY_CUSTOMSHAPEGEOMETRY,_customshapegeometry,m_CustomShapeGeometry); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +// ============================================================================= +}// namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/Tools.cxx b/reportdesign/source/core/api/Tools.cxx new file mode 100644 index 000000000000..2c72f9e9c3c0 --- /dev/null +++ b/reportdesign/source/core/api/Tools.cxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Tools.hxx" +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#include "core_resource.hrc" +#endif +#include "core_resource.hxx" +#include <comphelper/property.hxx> + +// ============================================================================= +namespace reportdesign +{ +// ============================================================================= +using namespace com::sun::star; + +uno::Reference< report::XSection> lcl_getSection(const uno::Reference< uno::XInterface>& _xReportComponent) +{ + uno::Reference< container::XChild> xChild(_xReportComponent,uno::UNO_QUERY); + uno::Reference< report::XSection> xRet(_xReportComponent,uno::UNO_QUERY); + while( !xRet.is() && xChild.is() ) + { + uno::Reference< uno::XInterface> xTemp = xChild->getParent(); + xChild.set(xTemp,uno::UNO_QUERY); + xRet.set(xTemp,uno::UNO_QUERY); + } + return xRet; +} +// ----------------------------------------------------------------------------- +void throwIllegallArgumentException( const ::rtl::OUString& _sTypeName + ,const uno::Reference< uno::XInterface >& ExceptionContext_ + ,const ::sal_Int16& ArgumentPosition_ + ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context_ + ) +{ + ::rtl::OUString sErrorMessage(RPT_RESSTRING(RID_STR_ERROR_WRONG_ARGUMENT,Context_->getServiceManager())); + sErrorMessage = sErrorMessage.replaceAt(sErrorMessage.indexOf('#'),2,_sTypeName); + throw lang::IllegalArgumentException(sErrorMessage,ExceptionContext_,ArgumentPosition_); +} +// ----------------------------------------------------------------------------- +uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent>& _xReportComponent + ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory + ,const ::rtl::OUString& _sServiceName) +{ + OSL_ENSURE(_xReportComponent.is() && _xFactory.is() ,"reportcomponent is null -> GPF"); + uno::Reference< report::XReportComponent> xClone(_xFactory->createInstance(_sServiceName),uno::UNO_QUERY_THROW); + ::comphelper::copyProperties(_xReportComponent.get(),xClone.get()); + return xClone.get(); +} +// ----------------------------------------------------------------------------- + +// ============================================================================= +} // namespace reportdesign +// ============================================================================= diff --git a/reportdesign/source/core/api/makefile.mk b/reportdesign/source/core/api/makefile.mk new file mode 100644 index 000000000000..f19d7486a0cd --- /dev/null +++ b/reportdesign/source/core/api/makefile.mk @@ -0,0 +1,63 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=reportdesign +TARGET=api + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/dll.pmk + +# --- Files ------------------------------------- +SLOFILES= \ + $(SLO)$/FormattedField.obj \ + $(SLO)$/Groups.obj \ + $(SLO)$/Group.obj \ + $(SLO)$/Section.obj \ + $(SLO)$/services.obj \ + $(SLO)$/FixedText.obj \ + $(SLO)$/ImageControl.obj \ + $(SLO)$/ReportDefinition.obj \ + $(SLO)$/ReportComponent.obj \ + $(SLO)$/ReportEngineJFree.obj \ + $(SLO)$/Tools.obj \ + $(SLO)$/Function.obj \ + $(SLO)$/Functions.obj \ + $(SLO)$/ReportControlModel.obj \ + $(SLO)$/FormatCondition.obj \ + $(SLO)$/ReportVisitor.obj \ + $(SLO)$/Shape.obj \ + $(SLO)$/FixedLine.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + diff --git a/reportdesign/source/core/api/services.cxx b/reportdesign/source/core/api/services.cxx new file mode 100644 index 000000000000..7598bc5d1ace --- /dev/null +++ b/reportdesign/source/core/api/services.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "sal/types.h" +#include <cppuhelper/factory.hxx> +#include <osl/diagnose.h> +#include <cppuhelper/implementationentry.hxx> +#include "ReportDefinition.hxx" +#include "FormattedField.hxx" +#include "FixedText.hxx" +#include "ImageControl.hxx" +#include "FormatCondition.hxx" +#include "ReportEngineJFree.hxx" +#include "Function.hxx" +#include "Shape.hxx" +#include "FixedLine.hxx" + +/********************************************************************************************/ + +using namespace ::reportdesign; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +//*************************************************************************************** +// +// registry functions +namespace +{ + +cppu::ImplementationEntry entries[] = { + { &OReportDefinition::create, &OReportDefinition::getImplementationName_Static, &OReportDefinition::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OFormattedField::create, &OFormattedField::getImplementationName_Static, &OFormattedField::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OFixedText::create, &OFixedText::getImplementationName_Static, &OFixedText::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OImageControl::create, &OImageControl::getImplementationName_Static, &OImageControl::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OFormatCondition::create, &OFormatCondition::getImplementationName_Static, &OFormatCondition::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OReportEngineJFree::create, &OReportEngineJFree::getImplementationName_Static, &OReportEngineJFree::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OFunction::create, &OFunction::getImplementationName_Static, &OFunction::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OShape::create, &OShape::getImplementationName_Static, &OShape::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { &OFixedLine::create, &OFixedLine::getImplementationName_Static, &OFixedLine::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } +}; +} + +extern "C" +{ +SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * implName, void * serviceManager, void * registryKey) +{ + return cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} + +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( + char const ** envTypeName, uno_Environment **) +{ + *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +} // extern "C" diff --git a/reportdesign/source/core/inc/FixedLine.hxx b/reportdesign/source/core/inc/FixedLine.hxx new file mode 100644 index 000000000000..dd7d14df57e2 --- /dev/null +++ b/reportdesign/source/core/inc/FixedLine.hxx @@ -0,0 +1,175 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPT_FIXEDLINE_HXX +#define RPT_FIXEDLINE_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/report/XFixedLine.hpp> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ReportHelperDefines.hxx" + + +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XFixedLine > FixedLinePropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XFixedLine + ,com::sun::star::lang::XServiceInfo > FixedLineBase; + + /** \class OFixedLine Defines the implementation of a \interface com:::sun::star::report::XFixedLine + * \ingroup reportdesign_api + * + */ + class OFixedLine : public comphelper::OBaseMutex, + public FixedLineBase, + public FixedLinePropertySet + { + friend class OShapeHelper; + OReportControlModel m_aProps; + ::com::sun::star::drawing::LineStyle m_LineStyle; + ::com::sun::star::drawing::LineDash m_LineDash; + sal_Int32 m_nOrientation; + ::sal_Int32 m_LineColor; + ::sal_Int16 m_LineTransparence; + ::sal_Int32 m_LineWidth; + + private: + OFixedLine(const OFixedLine&); + OFixedLine& operator=(const OFixedLine&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + l.notify(); + } + void checkIndex(sal_Int32 _nIndex); + protected: + virtual ~OFixedLine(); + public: + explicit OFixedLine(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); + explicit OFixedLine(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _xFactory + ,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape + ,sal_Int32 _nOrientation); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XReportComponent + REPORTCOMPONENT_HEADER() + + // XShape + SHAPE_HEADER() + + // XShapeDescriptor + virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException); + + // XReportControlModel + REPORTCONTROLMODEL_HEADER() + + // XFixedLine + virtual ::sal_Int32 SAL_CALL getOrientation() throw (::com::sun::star::beans::UnknownPropertyException,::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setOrientation( ::sal_Int32 _orientation ) throw (::com::sun::star::beans::UnknownPropertyException,::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::drawing::LineStyle SAL_CALL getLineStyle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLineStyle( ::com::sun::star::drawing::LineStyle _linestyle ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::drawing::LineDash SAL_CALL getLineDash() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLineDash( const ::com::sun::star::drawing::LineDash& _linedash ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getLineColor() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLineColor( ::sal_Int32 _linecolor ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getLineTransparence() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLineTransparence( ::sal_Int16 _linetransparence ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getLineWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLineWidth( ::sal_Int32 _linewidth ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::report::XReportControlFormat + REPORTCONTROLFORMAT_HEADER() + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif //RPT_FIXEDLINE_HXX + diff --git a/reportdesign/source/core/inc/FixedText.hxx b/reportdesign/source/core/inc/FixedText.hxx new file mode 100644 index 000000000000..9acdcb2d9148 --- /dev/null +++ b/reportdesign/source/core/inc/FixedText.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef RPT_FIXEDTEXT_HXX +#define RPT_FIXEDTEXT_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/report/XFixedText.hpp> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ReportHelperDefines.hxx" + + +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XFixedText > FixedTextPropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XFixedText + ,com::sun::star::lang::XServiceInfo > FixedTextBase; + + /** \class OFixedText Defines the implementation of a \interface com:::sun::star::report::XFixedText + * \ingroup reportdesign_api + * + */ + class OFixedText : public comphelper::OBaseMutex, + public FixedTextBase, + public FixedTextPropertySet + { + friend class OShapeHelper; + OReportControlModel m_aProps; + ::rtl::OUString m_sLabel; + private: + OFixedText(const OFixedText&); + OFixedText& operator=(const OFixedText&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( _member != _Value ) + { + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + } + l.notify(); + } + void checkIndex(sal_Int32 _nIndex); + protected: + virtual ~OFixedText(); + public: + explicit OFixedText(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); + explicit OFixedText(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _xFactory + ,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XReportComponent + REPORTCOMPONENT_HEADER() + // XShape + SHAPE_HEADER() + + // XShapeDescriptor + virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException); + + // XReportControlModel + REPORTCONTROLMODEL_HEADER() + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // XFixedText + virtual ::rtl::OUString SAL_CALL getLabel() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLabel( const ::rtl::OUString& _label ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::report::XReportControlFormat + REPORTCONTROLFORMAT_HEADER() + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif //RPT_FIXEDTEXT_HXX + diff --git a/reportdesign/source/core/inc/FormatCondition.hxx b/reportdesign/source/core/inc/FormatCondition.hxx new file mode 100644 index 000000000000..82628270395b --- /dev/null +++ b/reportdesign/source/core/inc/FormatCondition.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPT_FORMATCONDITION_HXX +#define RPT_FORMATCONDITION_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/report/XFormatCondition.hpp> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ReportHelperDefines.hxx" + +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XFormatCondition > FormatConditionPropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XFormatCondition + ,com::sun::star::lang::XServiceInfo > FormatConditionBase; + + /** \class OFormatCondition Defines the implementation of a \interface com:::sun::star::report::XFormatCondition + * \ingroup reportdesign_api + * + */ + class OFormatCondition : public comphelper::OBaseMutex, + public FormatConditionBase, + public FormatConditionPropertySet + { + OFormatProperties m_aFormatProperties; + ::rtl::OUString m_sFormula; + sal_Bool m_bEnabled; + private: + OFormatCondition(const OFormatCondition&); + OFormatCondition& operator=(const OFormatCondition&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + l.notify(); + } + protected: + virtual ~OFormatCondition(); + public: + explicit OFormatCondition(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XFormatCondition + virtual ::sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getFormula() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFormula( const ::rtl::OUString& _formula ) throw (::com::sun::star::uno::RuntimeException); + + // XReportControlFormat + REPORTCONTROLFORMAT_HEADER() + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + }; +} +#endif //RPT_FORMATCONDITION_HXX + diff --git a/reportdesign/source/core/inc/FormattedField.hxx b/reportdesign/source/core/inc/FormattedField.hxx new file mode 100644 index 000000000000..9f1186dc23d5 --- /dev/null +++ b/reportdesign/source/core/inc/FormattedField.hxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPT_FORMATTEDFIELD_HXX +#define RPT_FORMATTEDFIELD_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/report/XFormattedField.hpp> +#include <com/sun/star/report/Function.hpp> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ReportHelperDefines.hxx" +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XFormattedField > FormattedFieldPropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XFormattedField + ,com::sun::star::lang::XServiceInfo > FormattedFieldBase; + + /** \class OFormattedField Defines the implementation of a \interface com:::sun::star::report::XFormattedField + * \ingroup reportdesign_api + * + */ + class OFormattedField : public comphelper::OBaseMutex, + public FormattedFieldBase, + public FormattedFieldPropertySet + { + friend class OShapeHelper; + + OReportControlModel m_aProps; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > + m_xFormatsSupplier; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction> m_xFunction; + ::sal_Int32 m_nFormatKey; + + private: + OFormattedField(const OFormattedField&); + OFormattedField& operator=(const OFormattedField&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( _member != _Value ) + { + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + } + l.notify(); + } + void checkIndex(sal_Int32 _nIndex); + protected: + virtual ~OFormattedField(); + public: + explicit OFormattedField(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); + explicit OFormattedField(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _xFactory + ,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XReportComponent + REPORTCOMPONENT_HEADER() + + // XShape + SHAPE_HEADER() + + // XShapeDescriptor + virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException); + + // XReportControlModel + REPORTCONTROLMODEL_HEADER() + + // XReportControlFormat + REPORTCONTROLFORMAT_HEADER() + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // XFormattedField + virtual ::sal_Int32 SAL_CALL getFormatKey() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFormatKey(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > SAL_CALL getFormatsSupplier() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFormatsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _formatssupplier ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif //RPT_FORMATTEDFIELD_HXX + diff --git a/reportdesign/source/core/inc/Function.hxx b/reportdesign/source/core/inc/Function.hxx new file mode 100644 index 000000000000..cd4364ef2659 --- /dev/null +++ b/reportdesign/source/core/inc/Function.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPT_FUNCTION_HXX +#define RPT_FUNCTION_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#ifndef _COM_SUN_STAR_REPORT_XFunction_HPP_ +#include <com/sun/star/report/XFunction.hpp> +#endif +#include <cppuhelper/basemutex.hxx> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XFunction > FunctionPropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XFunction + ,com::sun::star::lang::XServiceInfo > FunctionBase; + + /** \class OFunction Defines the implementation of a \interface com:::sun::star::report::XFunction + * \ingroup reportdesign_api + * + */ + class OFunction : public cppu::BaseMutex, + public FunctionBase, + public FunctionPropertySet + { + com::sun::star::beans::Optional< ::rtl::OUString> m_sInitialFormula; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XFunctions > m_xParent; + ::rtl::OUString m_sName; + ::rtl::OUString m_sFormula; + ::sal_Bool m_bPreEvaluated; + ::sal_Bool m_bDeepTraversing; + private: + OFunction(const OFunction&); + OFunction& operator=(const OFunction&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + l.notify(); + } + protected: + virtual ~OFunction(); + public: + explicit OFunction(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::report::XFunction: + virtual ::sal_Bool SAL_CALL getPreEvaluated() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPreEvaluated(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getDeepTraversing() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDeepTraversing(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getFormula() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFormula(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException); + virtual com::sun::star::beans::Optional< ::rtl::OUString> SAL_CALL getInitialFormula() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInitialFormula(const com::sun::star::beans::Optional< ::rtl::OUString> & the_value) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif //RPT_FUNCTION_HXX + diff --git a/reportdesign/source/core/inc/Functions.hxx b/reportdesign/source/core/inc/Functions.hxx new file mode 100644 index 000000000000..a6d2e8751a55 --- /dev/null +++ b/reportdesign/source/core/inc/Functions.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_API_FUNCTIONS_HXX +#define REPORTDESIGN_API_FUNCTIONS_HXX + +#include <com/sun/star/report/XFunctions.hpp> +#include <com/sun/star/report/XFunctionsSupplier.hpp> +#include <cppuhelper/compbase1.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <list> + + +namespace reportdesign +{ + typedef ::cppu::WeakComponentImplHelper1< com::sun::star::report::XFunctions> FunctionsBase; + /** \class OFunctions Defines the implementation of a \interface com:::sun::star::report::XFunctions + * \ingroup reportdesign_api + * + */ + class OFunctions : public comphelper::OBaseMutex, + public FunctionsBase + { + typedef ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > > TFunctions; + ::cppu::OInterfaceContainerHelper m_aContainerListeners; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XFunctionsSupplier > m_xParent; + TFunctions m_aFunctions; + private: + OFunctions& operator=(const OFunctions&); + OFunctions(const OFunctions&); + void checkIndex(sal_Int32 _nIndex); + protected: + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual ~OFunctions(); + + /** this function is called upon disposing the component + */ + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual void SAL_CALL disposing(); + public: + explicit OFunctions( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier >& _xParent + ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context); + + // XFunctions + // Methods + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > SAL_CALL createFunction( ) throw (::com::sun::star::uno::RuntimeException); + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + }; +} +#endif // REPORTDESIGN_API_FUNCTIONS_HXX + diff --git a/reportdesign/source/core/inc/Group.hxx b/reportdesign/source/core/inc/Group.hxx new file mode 100644 index 000000000000..008435333217 --- /dev/null +++ b/reportdesign/source/core/inc/Group.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_API_GROUP_HXX +#define REPORTDESIGN_API_GROUP_HXX + +#include <com/sun/star/report/XGroup.hpp> +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/sequence.hxx> +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include "GroupProperties.hxx" +#include <comphelper/uno3.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace reportdesign +{ + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XGroup + , ::com::sun::star::lang::XServiceInfo> GroupBase; + typedef ::cppu::PropertySetMixin< com::sun::star::report::XGroup> GroupPropertySet; + + /** \class OGroup Defines the implementation of a \interface com:::sun::star::report::XGroup + * \ingroup reportdesign_api + * + */ + class OGroup : public comphelper::OMutexAndBroadcastHelper + ,public GroupBase + ,public GroupPropertySet + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XGroups > m_xParent; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> m_xHeader; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> m_xFooter; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctions > m_xFunctions; + ::rptshared::GroupProperties m_aProps; + + private: + OGroup& operator=(const OGroup&); + OGroup(const OGroup&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( _member != _Value ) + { + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + } + l.notify(); + } + void setSection( const ::rtl::OUString& _sProperty + ,const sal_Bool& _bOn + ,const ::rtl::OUString& _sName + ,::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _member); + protected: + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual ~OGroup(); + + /** this function is called upon disposing the component + */ + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual void SAL_CALL disposing(); + public: + OGroup(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroups >& _xParent + ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context); + + void copyGroup(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xSource); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XGroup + virtual ::sal_Bool SAL_CALL getSortAscending() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSortAscending( ::sal_Bool _sortascending ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getHeaderOn() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHeaderOn( ::sal_Bool _headeron ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getFooterOn() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFooterOn( ::sal_Bool _footeron ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > SAL_CALL getHeader() throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > SAL_CALL getFooter() throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getGroupOn() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setGroupOn( ::sal_Int16 _groupon ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getGroupInterval() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setGroupInterval( ::sal_Int32 _groupinterval ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getKeepTogether() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setKeepTogether( ::sal_Int16 _keeptogether ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroups > SAL_CALL getGroups() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExpression() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setExpression( const ::rtl::OUString& _expression ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getStartNewColumn() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStartNewColumn( ::sal_Bool _startnewcolumn ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getResetPageNumber() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setResetPageNumber( ::sal_Bool _resetpagenumber ) throw (::com::sun::star::uno::RuntimeException); + + //XFunctionsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctions > SAL_CALL getFunctions() throw (::com::sun::star::uno::RuntimeException); + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext(){ return m_xContext; } + }; +// ============================================================================= +} // namespace reportdesign +// ============================================================================= +#endif // diff --git a/reportdesign/source/core/inc/Groups.hxx b/reportdesign/source/core/inc/Groups.hxx new file mode 100644 index 000000000000..c888fae5926f --- /dev/null +++ b/reportdesign/source/core/inc/Groups.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_API_GROUPS_HXX +#define REPORTDESIGN_API_GROUPS_HXX + +#include <com/sun/star/report/XGroups.hpp> +#include <cppuhelper/compbase1.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <list> + + +namespace reportdesign +{ + typedef ::cppu::WeakComponentImplHelper1< com::sun::star::report::XGroups> GroupsBase; + /** \class OGroups Defines the implementation of a \interface com:::sun::star::report::XGroups + * \ingroup reportdesign_api + * + */ + class OGroups : public comphelper::OBaseMutex, + public GroupsBase + { + typedef ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > > TGroups; + ::cppu::OInterfaceContainerHelper m_aContainerListeners; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XReportDefinition > m_xParent; + TGroups m_aGroups; + private: + OGroups& operator=(const OGroups&); + OGroups(const OGroups&); + void checkIndex(sal_Int32 _nIndex); + protected: + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual ~OGroups(); + + /** this function is called upon disposing the component + */ + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual void SAL_CALL disposing(); + public: + OGroups( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xParent + ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context); + + void copyGroups(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroups >& _xSource); + + // XGroups + // Attributes + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > SAL_CALL getReportDefinition() throw (::com::sun::star::uno::RuntimeException); + // Methods + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > SAL_CALL createGroup( ) throw (::com::sun::star::uno::RuntimeException); + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + }; +} +#endif // REPORTDESIGN_API_GROUPS_HXX + diff --git a/reportdesign/source/core/inc/ImageControl.hxx b/reportdesign/source/core/inc/ImageControl.hxx new file mode 100644 index 000000000000..7dc65804ab48 --- /dev/null +++ b/reportdesign/source/core/inc/ImageControl.hxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPT_IMAGECONTROL_HXX +#define RPT_IMAGECONTROL_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/report/XImageControl.hpp> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ReportHelperDefines.hxx" + +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XImageControl > ImageControlPropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XImageControl + ,com::sun::star::lang::XServiceInfo > ImageControlBase; + + /** \class OImageControl Defines the implementation of a \interface com:::sun::star::report::XImageControl + * \ingroup reportdesign_api + * + */ + class OImageControl : public comphelper::OBaseMutex, + public ImageControlBase, + public ImageControlPropertySet + { + friend class OShapeHelper; + OReportControlModel m_aProps; + ::rtl::OUString m_aImageURL; + sal_Int16 m_nScaleMode; + ::sal_Bool m_bPreserveIRI; + private: + OImageControl(const OImageControl&); + OImageControl& operator=(const OImageControl&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + l.notify(); + } + void checkIndex(sal_Int32 _nIndex); + protected: + virtual ~OImageControl(); + public: + explicit OImageControl(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); + explicit OImageControl(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _xFactory + ,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XReportComponent + REPORTCOMPONENT_HEADER() + // XShape + SHAPE_HEADER() + + // XShapeDescriptor + virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException); + + // XReportControlModel + REPORTCONTROLMODEL_HEADER() + + // XReportControlFormat + REPORTCONTROLFORMAT_HEADER() + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // XImageControl + virtual ::rtl::OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getPreserveIRI() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPreserveIRI( ::sal_Bool _preserveiri ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getScaleMode() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setScaleMode( ::sal_Int16 _scalemode ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + // XImageProducerSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer > SAL_CALL getImageProducer( ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif //RPT_IMAGECONTROL_HXX + diff --git a/reportdesign/source/core/inc/ReportComponent.hxx b/reportdesign/source/core/inc/ReportComponent.hxx new file mode 100644 index 000000000000..6ed9496a9f59 --- /dev/null +++ b/reportdesign/source/core/inc/ReportComponent.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef RPT_REPORTCOMPONENT_HXX +#define RPT_REPORTCOMPONENT_HXX + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/report/XReportComponent.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <cppuhelper/weakref.hxx> +#include <comphelper/uno3.hxx> + +namespace reportdesign +{ + class OReportComponentProperties + { + public: + ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XChild > m_xParent; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xShape; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxy; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xProperty; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xUnoTunnel; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aMasterFields; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aDetailFields; + ::rtl::OUString m_sName; + ::sal_Int32 m_nHeight; + ::sal_Int32 m_nWidth; + ::sal_Int32 m_nPosX; + ::sal_Int32 m_nPosY; + ::sal_Int32 m_nBorderColor; + ::sal_Int16 m_nBorder; + ::sal_Bool m_bPrintRepeatedValues; + + OReportComponentProperties(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ) + :m_xContext(_xContext) + ,m_nHeight(0) + ,m_nWidth(0) + ,m_nPosX(0) + ,m_nPosY(0) + ,m_nBorderColor(0) + ,m_nBorder(2) + ,m_bPrintRepeatedValues(sal_True) + {} + ~OReportComponentProperties(); + + void setShape(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xTunnel + ,oslInterlockedCount& _rRefCount); + }; +} +#endif // RPT_REPORTCOMPONENT_HXX + diff --git a/reportdesign/source/core/inc/ReportControlModel.hxx b/reportdesign/source/core/inc/ReportControlModel.hxx new file mode 100644 index 000000000000..4da5cc9df349 --- /dev/null +++ b/reportdesign/source/core/inc/ReportControlModel.hxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef RPT_REPORTCONTROLMODEL_HXX +#define RPT_REPORTCONTROLMODEL_HXX + +#include "ReportComponent.hxx" +#include "com/sun/star/style/VerticalAlignment.hpp" +#include "com/sun/star/awt/FontDescriptor.hpp" +#include "com/sun/star/report/XFormatCondition.hpp" +#include "com/sun/star/container/XContainer.hpp" +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <tools/color.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.h> + + +namespace reportdesign +{ + bool operator==( const ::com::sun::star::awt::FontDescriptor& _lhs, const ::com::sun::star::awt::FontDescriptor& _rhs ); + + inline bool operator!=( const ::com::sun::star::awt::FontDescriptor& _lhs, const ::com::sun::star::awt::FontDescriptor& _rhs ) + { + return !( _lhs == _rhs ); + } + + struct OFormatProperties + { + ::sal_Int16 nAlign; + ::com::sun::star::awt::FontDescriptor aFontDescriptor; + ::com::sun::star::awt::FontDescriptor aAsianFontDescriptor; + ::com::sun::star::awt::FontDescriptor aComplexFontDescriptor; + ::com::sun::star::lang::Locale aCharLocale; + ::com::sun::star::lang::Locale aCharLocaleAsian; + ::com::sun::star::lang::Locale aCharLocaleComplex; + ::sal_Int16 nFontEmphasisMark; + ::sal_Int16 nFontRelief; + ::sal_Int32 nTextColor; + ::sal_Int32 nTextLineColor; + ::sal_Int32 nCharUnderlineColor; + ::sal_Int32 nBackgroundColor; + ::rtl::OUString sCharCombinePrefix; + ::rtl::OUString sCharCombineSuffix; + ::rtl::OUString sHyperLinkURL; + ::rtl::OUString sHyperLinkTarget; + ::rtl::OUString sHyperLinkName; + ::rtl::OUString sVisitedCharStyleName; + ::rtl::OUString sUnvisitedCharStyleName; + com::sun::star::style::VerticalAlignment aVerticalAlignment; + ::sal_Int16 nCharEscapement; + ::sal_Int16 nCharCaseMap; + ::sal_Int16 nCharKerning; + ::sal_Int8 nCharEscapementHeight; + ::sal_Bool m_bBackgroundTransparent; + ::sal_Bool bCharFlash; + ::sal_Bool bCharAutoKerning; + ::sal_Bool bCharCombineIsOn; + ::sal_Bool bCharHidden; + ::sal_Bool bCharShadowed; + ::sal_Bool bCharContoured; + OFormatProperties(); + }; + class OReportControlModel + { + void checkIndex(sal_Int32 _nIndex); + OReportControlModel(OReportControlModel&); + void operator =(OReportControlModel&); + public: + ::cppu::OInterfaceContainerHelper aContainerListeners; + OReportComponentProperties aComponent; + OFormatProperties aFormatProperties; + ::com::sun::star::container::XContainer* m_pOwner; + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormatCondition> > + m_aFormatConditions; + osl::Mutex& m_rMutex; + ::rtl::OUString aDataField; + ::rtl::OUString aConditionalPrintExpression; + sal_Bool bPrintWhenGroupChange; + + OReportControlModel(osl::Mutex& _rMutex + ,::com::sun::star::container::XContainer* _pOwner + ,::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext) + :aContainerListeners(_rMutex) + ,aComponent(_xContext) + ,m_pOwner(_pOwner) + ,m_rMutex(_rMutex) + ,bPrintWhenGroupChange(sal_False) + {} + + // XContainer + void addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + void removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + ::sal_Bool hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexReplace + void replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexContainer + void insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + void removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + ::sal_Int32 getCount( ) throw (::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + static bool isInterfaceForbidden(const ::com::sun::star::uno::Type& _rType); + }; +} +#endif // RPT_REPORTCONTROLMODEL_HXX + diff --git a/reportdesign/source/core/inc/ReportDrawPage.hxx b/reportdesign/source/core/inc/ReportDrawPage.hxx new file mode 100644 index 000000000000..87f34c0f1065 --- /dev/null +++ b/reportdesign/source/core/inc/ReportDrawPage.hxx @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef REPORTDRAWPAGE_HXX_INCLUDED +#define REPORTDRAWPAGE_HXX_INCLUDED + +#include <svx/unopage.hxx> +#include <com/sun/star/report/XSection.hpp> + +namespace reportdesign +{ + class OReportDrawPage : public SvxDrawPage + { + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XSection > m_xSection; + OReportDrawPage(const OReportDrawPage&); + void operator =(const OReportDrawPage&); + protected: + virtual SdrObject *_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape )throw (); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > _CreateShape( SdrObject *pObj ) const throw (); + public: + OReportDrawPage(SdrPage* pPage,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection); + virtual ~OReportDrawPage() throw(){} + }; +} +#endif //REPORTDRAWPAGE_HXX_INCLUDED + diff --git a/reportdesign/source/core/inc/ReportEngineJFree.hxx b/reportdesign/source/core/inc/ReportEngineJFree.hxx new file mode 100644 index 000000000000..1a53f24f2d7c --- /dev/null +++ b/reportdesign/source/core/inc/ReportEngineJFree.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_API_REPORTENGINEJFREE_HXX +#define REPORTDESIGN_API_REPORTENGINEJFREE_HXX + +#include <com/sun/star/report/XReportEngine.hpp> +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/uno3.hxx> +#include <comphelper/types.hxx> +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <comphelper/stl_types.hxx> +#include <comphelper/implementationreference.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace reportdesign +{ + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XReportEngine + ,com::sun::star::lang::XServiceInfo> ReportEngineBase; + typedef ::cppu::PropertySetMixin<com::sun::star::report::XReportEngine> ReportEnginePropertySet; + + class OReportEngineJFree : public comphelper::OMutexAndBroadcastHelper, + public ReportEngineBase, + public ReportEnginePropertySet + { + typedef ::std::multimap< ::rtl::OUString, ::com::sun::star::uno::Any , ::comphelper::UStringMixLess> TComponentMap; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReport; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator> m_StatusIndicator; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection; + ::sal_Int32 m_nMaxRows; + private: + OReportEngineJFree(const OReportEngineJFree&); + OReportEngineJFree& operator=(const OReportEngineJFree&); + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + l.notify(); + } + + /** returns the file url for a new model + * + * \return The new file url. + */ + ::rtl::OUString getNewOutputName(); + + protected: + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual ~OReportEngineJFree(); + public: + typedef ::comphelper::ImplementationReference< OReportEngineJFree ,::com::sun::star::report::XReportEngine,::com::sun::star::uno::XWeak > TReportEngine; + + OReportEngineJFree(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + private: + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XReportEngine + // Attributes + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > SAL_CALL getReportDefinition() throw (::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL setReportDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _reportdefinition ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getActiveConnection() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _activeconnection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > SAL_CALL getStatusIndicator() throw (::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL setStatusIndicator( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& _statusindicator ) throw (::com::sun::star::uno::RuntimeException) ; + virtual ::sal_Int32 SAL_CALL getMaxRows() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMaxRows( ::sal_Int32 _MaxRows ) throw (::com::sun::star::uno::RuntimeException); + // Methods + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL createDocumentModel( ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL createDocumentAlive( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _frame ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL createDocumentAlive( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _frame ,bool _bHidden) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::util::URL SAL_CALL createDocument( ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL interrupt( ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ; + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + }; +} +#endif //REPORTDESIGN_API_REPORTENGINEJFREE_HXX diff --git a/reportdesign/source/core/inc/ReportHelperImpl.hxx b/reportdesign/source/core/inc/ReportHelperImpl.hxx new file mode 100644 index 000000000000..d0eb2490dbbd --- /dev/null +++ b/reportdesign/source/core/inc/ReportHelperImpl.hxx @@ -0,0 +1,1291 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef INCLUDED_REPORTHELPERIMPL_HXX +#define INCLUDED_REPORTHELPERIMPL_HXX +// ::com::sun::star::report::XReportComponent: +#define REPORTCOMPONENT_IMPL3(clazz,arg) \ +::rtl::OUString SAL_CALL clazz::getName() throw (uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return (arg).m_sName; \ +} \ +void SAL_CALL clazz::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException,beans::PropertyVetoException) \ +{ \ + set(PROPERTY_NAME,_name,(arg).m_sName); \ +} \ +::sal_Int32 SAL_CALL clazz::getHeight() throw (uno::RuntimeException) \ +{ \ + return getSize().Height; \ +} \ +void SAL_CALL clazz::setHeight( ::sal_Int32 _height ) throw (uno::RuntimeException) \ +{ \ + awt::Size aSize = getSize(); \ + aSize.Height = _height; \ + setSize(aSize); \ +} \ +::sal_Int32 SAL_CALL clazz::getPositionX() throw (uno::RuntimeException) \ +{ \ + return getPosition().X; \ +} \ +void SAL_CALL clazz::setPositionX( ::sal_Int32 _positionx ) throw (uno::RuntimeException) \ +{ \ + awt::Point aPos = getPosition(); \ + aPos.X = _positionx; \ + setPosition(aPos); \ +} \ +::sal_Int32 SAL_CALL clazz::getPositionY() throw (uno::RuntimeException) \ +{ \ + return getPosition().Y; \ +} \ +void SAL_CALL clazz::setPositionY( ::sal_Int32 _positiony ) throw (uno::RuntimeException) \ +{ \ + awt::Point aPos = getPosition(); \ + aPos.Y = _positiony; \ + setPosition(aPos); \ +} \ +::sal_Int32 SAL_CALL clazz::getWidth() throw (uno::RuntimeException) \ +{ \ + return getSize().Width; \ +} \ +void SAL_CALL clazz::setWidth( ::sal_Int32 _width ) throw (uno::RuntimeException) \ +{ \ + awt::Size aSize = getSize(); \ + aSize.Width = _width; \ + setSize(aSize); \ +} \ +uno::Reference< report::XSection > SAL_CALL clazz::getSection() throw (uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + uno::Reference< container::XChild > xParent(getParent( ),uno::UNO_QUERY); \ + return lcl_getSection(xParent); \ +} + +#define REPORTCOMPONENT_IMPL(clazz,arg) \ +REPORTCOMPONENT_IMPL3(clazz,arg)\ +::sal_Bool SAL_CALL clazz::getPrintRepeatedValues() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return (arg).m_bPrintRepeatedValues; \ +} \ +void SAL_CALL clazz::setPrintRepeatedValues( ::sal_Bool _printrepeatedvalues ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_PRINTREPEATEDVALUES,_printrepeatedvalues,(arg).m_bPrintRepeatedValues); \ +} + +#define REPORTCOMPONENT_IMPL2(clazz,arg) \ +::sal_Int16 SAL_CALL clazz::getControlBorder() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return (arg).m_nBorder; \ +} \ +void SAL_CALL clazz::setControlBorder( ::sal_Int16 _border ) throw (uno::RuntimeException,lang::IllegalArgumentException,beans::UnknownPropertyException)\ +{ \ + set(PROPERTY_CONTROLBORDER,_border,(arg).m_nBorder); \ +} \ +::sal_Int32 SAL_CALL clazz::getControlBorderColor() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return (arg).m_nBorderColor; \ +} \ +void SAL_CALL clazz::setControlBorderColor( ::sal_Int32 _bordercolor ) throw (uno::RuntimeException, lang::IllegalArgumentException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CONTROLBORDERCOLOR,_bordercolor,(arg).m_nBorderColor); \ +} + +#define REPORTCOMPONENT_MASTERDETAIL(clazz,arg) \ +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL clazz::getMasterFields() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return (arg).m_aMasterFields; \ +} \ +void SAL_CALL clazz::setMasterFields( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _masterfields ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + set(PROPERTY_MASTERFIELDS,_masterfields,(arg).m_aMasterFields); \ +} \ +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL clazz::getDetailFields() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return (arg).m_aDetailFields; \ +} \ +void SAL_CALL clazz::setDetailFields( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _detailfields ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + set(PROPERTY_DETAILFIELDS,_detailfields,(arg).m_aDetailFields); \ +} + +#define REPORTCOMPONENT_NOMASTERDETAIL(clazz) \ +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL clazz::getMasterFields() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) \ +{ \ + throw ::com::sun::star::beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setMasterFields( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + throw ::com::sun::star::beans::UnknownPropertyException();\ +} \ +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL clazz::getDetailFields() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + throw ::com::sun::star::beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setDetailFields( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + throw ::com::sun::star::beans::UnknownPropertyException();\ +} + +// ::com::sun::star::report::XReportControlFormat: +#define REPORTCONTROLFORMAT_IMPL1(clazz,varName) \ +::sal_Int32 SAL_CALL clazz::getControlBackground() throw (::com::sun::star::beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.m_bBackgroundTransparent ? COL_TRANSPARENT : varName.nBackgroundColor; \ +} \ + \ +void SAL_CALL clazz::setControlBackground( ::sal_Int32 _backgroundcolor ) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + sal_Bool bTransparent = _backgroundcolor == static_cast<sal_Int32>(COL_TRANSPARENT);\ + setControlBackgroundTransparent(bTransparent);\ + if ( !bTransparent )\ + set(PROPERTY_CONTROLBACKGROUND,_backgroundcolor,varName.nBackgroundColor);\ +} \ + \ +::sal_Bool SAL_CALL clazz::getControlBackgroundTransparent() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.m_bBackgroundTransparent; \ +} \ + \ +void SAL_CALL clazz::setControlBackgroundTransparent( ::sal_Bool _controlbackgroundtransparent ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CONTROLBACKGROUNDTRANSPARENT,_controlbackgroundtransparent,varName.m_bBackgroundTransparent);\ + if ( _controlbackgroundtransparent )\ + set(PROPERTY_CONTROLBACKGROUND,static_cast<sal_Int32>(COL_TRANSPARENT),varName.nBackgroundColor);\ +} + +#define REPORTCONTROLFORMAT_IMPL2(clazz,varName) \ +::sal_Int16 SAL_CALL clazz::getCharStrikeout() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Strikeout; \ +} \ + \ +void SAL_CALL clazz::setCharStrikeout(::sal_Int16 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARSTRIKEOUT,the_value,varName.aFontDescriptor.Strikeout); \ +} \ + \ +::sal_Bool SAL_CALL clazz::getCharWordMode() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.WordLineMode; \ +} \ + \ +void SAL_CALL clazz::setCharWordMode(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARWORDMODE,the_value,varName.aFontDescriptor.WordLineMode); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharRotation() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return static_cast<sal_Int16>(varName.aFontDescriptor.Orientation); \ +} \ + \ +void SAL_CALL clazz::setCharRotation(::sal_Int16 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + float newValue = the_value; \ + set(PROPERTY_CHARROTATION,newValue,varName.aFontDescriptor.Orientation); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharScaleWidth() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return static_cast<sal_Int16>(varName.aFontDescriptor.CharacterWidth); \ +} \ + \ +void SAL_CALL clazz::setCharScaleWidth(::sal_Int16 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + float newValue = the_value; \ + set(PROPERTY_CHARSCALEWIDTH,newValue,varName.aFontDescriptor.CharacterWidth); \ +} \ +sal_Int16 SAL_CALL clazz::getParaAdjust() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nAlign; \ +} \ + \ +void SAL_CALL clazz::setParaAdjust( sal_Int16 _align ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_PARAADJUST,_align,varName.nAlign); \ +} \ + \ +awt::FontDescriptor SAL_CALL clazz::getFontDescriptor() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor; \ +} \ + \ +void SAL_CALL clazz::setFontDescriptor( const awt::FontDescriptor& _fontdescriptor ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_FONTDESCRIPTOR,_fontdescriptor,varName.aFontDescriptor); \ +} \ +awt::FontDescriptor SAL_CALL clazz::getFontDescriptorAsian() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor; \ +} \ + \ +void SAL_CALL clazz::setFontDescriptorAsian( const awt::FontDescriptor& _fontdescriptor ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_FONTDESCRIPTORASIAN,_fontdescriptor,varName.aAsianFontDescriptor); \ +} \ +awt::FontDescriptor SAL_CALL clazz::getFontDescriptorComplex() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor; \ +} \ + \ +void SAL_CALL clazz::setFontDescriptorComplex( const awt::FontDescriptor& _fontdescriptor ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_FONTDESCRIPTORCOMPLEX,_fontdescriptor,varName.aComplexFontDescriptor); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getControlTextEmphasis() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nFontEmphasisMark; \ +} \ + \ +void SAL_CALL clazz::setControlTextEmphasis( ::sal_Int16 _fontemphasismark ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_CONTROLTEXTEMPHASISMARK,_fontemphasismark,varName.nFontEmphasisMark); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharRelief() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nFontRelief; \ +} \ + \ +void SAL_CALL clazz::setCharRelief( ::sal_Int16 _fontrelief ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARRELIEF,_fontrelief,varName.nFontRelief); \ +} \ + \ +::sal_Int32 SAL_CALL clazz::getCharColor() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nTextColor; \ +} \ + \ +void SAL_CALL clazz::setCharColor( ::sal_Int32 _textcolor ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARCOLOR,_textcolor,varName.nTextColor); \ +} \ + \ +::sal_Int32 SAL_CALL clazz::getCharUnderlineColor() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nTextLineColor; \ +} \ + \ +void SAL_CALL clazz::setCharUnderlineColor( ::sal_Int32 _textlinecolor ) throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARUNDERLINECOLOR,_textlinecolor,varName.nTextLineColor); \ +} \ + \ +style::VerticalAlignment SAL_CALL clazz::getVerticalAlign() throw (beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aVerticalAlignment; \ +} \ + \ +void SAL_CALL clazz::setVerticalAlign( style::VerticalAlignment _verticalalign ) throw (lang::IllegalArgumentException,beans::UnknownPropertyException,uno::RuntimeException) \ +{ \ + set(PROPERTY_VERTICALALIGN,_verticalalign,varName.aVerticalAlignment); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharEmphasis() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + return getControlTextEmphasis(); \ +} \ + \ +void SAL_CALL clazz::setCharEmphasis( ::sal_Int16 _charemphasis ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHAREMPHASIS,_charemphasis,varName.nFontEmphasisMark); \ +} \ + \ +::rtl::OUString SAL_CALL clazz::getCharFontName() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Name; \ +} \ + \ +void SAL_CALL clazz::setCharFontName( const ::rtl::OUString& _charfontname ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARFONTNAME,_charfontname,varName.aFontDescriptor.Name); \ +} \ + \ +::rtl::OUString SAL_CALL clazz::getCharFontStyleName() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.StyleName; \ +} \ + \ +void SAL_CALL clazz::setCharFontStyleName( const ::rtl::OUString& _charfontstylename ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARFONTSTYLENAME,_charfontstylename,varName.aFontDescriptor.StyleName); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharFontFamily() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Family; \ +} \ + \ +void SAL_CALL clazz::setCharFontFamily( ::sal_Int16 _charfontfamily ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARFONTFAMILY,_charfontfamily,varName.aFontDescriptor.Family); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharFontCharSet() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.CharSet; \ +} \ + \ +void SAL_CALL clazz::setCharFontCharSet( ::sal_Int16 _charfontcharset ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARFONTCHARSET,_charfontcharset,varName.aFontDescriptor.CharSet); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharFontPitch() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Pitch; \ +} \ + \ +void SAL_CALL clazz::setCharFontPitch( ::sal_Int16 _charfontpitch ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARFONTPITCH,_charfontpitch,varName.aFontDescriptor.Pitch); \ +} \ + \ +float SAL_CALL clazz::getCharHeight() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Height; \ +} \ + \ +void SAL_CALL clazz::setCharHeight( float _charheight ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARHEIGHT,static_cast<sal_Int16>(_charheight),varName.aFontDescriptor.Height); \ +} \ + \ +::sal_Int16 SAL_CALL clazz::getCharUnderline() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Underline; \ +} \ + \ +void SAL_CALL clazz::setCharUnderline( ::sal_Int16 _charunderline ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARUNDERLINE,_charunderline,varName.aFontDescriptor.Underline); \ +} \ + \ +float SAL_CALL clazz::getCharWeight() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Weight; \ +} \ + \ +void SAL_CALL clazz::setCharWeight( float _charweight ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARWEIGHT,_charweight,varName.aFontDescriptor.Weight); \ +} \ + \ +awt::FontSlant SAL_CALL clazz::getCharPosture() throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aFontDescriptor.Slant; \ +} \ + \ +void SAL_CALL clazz::setCharPosture( awt::FontSlant _charposture ) throw (beans::UnknownPropertyException, uno::RuntimeException) \ +{ \ + set(PROPERTY_CHARPOSTURE,_charposture,varName.aFontDescriptor.Slant); \ +}\ +::sal_Bool SAL_CALL clazz::getCharFlash() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.bCharFlash; \ +} \ +void SAL_CALL clazz::setCharFlash(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + set(PROPERTY_CHARFLASH,the_value,varName.bCharFlash); \ +}\ +::sal_Bool SAL_CALL clazz::getCharAutoKerning() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.bCharAutoKerning; \ +} \ +void SAL_CALL clazz::setCharAutoKerning(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + set(PROPERTY_CHARAUTOKERNING,the_value,varName.bCharAutoKerning); \ +}\ +::sal_Int8 SAL_CALL clazz::getCharEscapementHeight() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nCharEscapementHeight; \ +} \ +void SAL_CALL clazz::setCharEscapementHeight(::sal_Int8 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARESCAPEMENTHEIGHT,the_value,varName.nCharEscapementHeight); \ +}\ +lang::Locale SAL_CALL clazz::getCharLocale() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aCharLocale; \ +} \ +void SAL_CALL clazz::setCharLocale(const lang::Locale & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + BoundListeners l; \ + { \ + ::osl::MutexGuard aGuard(m_aMutex); \ + if ( varName.aCharLocale.Language != the_value.Language \ + || varName.aCharLocale.Country != the_value.Country \ + || varName.aCharLocale.Variant != the_value.Variant ) \ + { \ + prepareSet(PROPERTY_CHARLOCALE, ::com::sun::star::uno::makeAny(varName.aCharLocale), ::com::sun::star::uno::makeAny(the_value), &l); \ + varName.aCharLocale = the_value; \ + } \ + } \ + l.notify(); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharEscapement() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nCharEscapement; \ +} \ +void SAL_CALL clazz::setCharEscapement(::sal_Int16 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARESCAPEMENT,the_value,varName.nCharEscapement); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharCaseMap() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nCharCaseMap; \ +} \ +void SAL_CALL clazz::setCharCaseMap(::sal_Int16 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARCASEMAP,the_value,varName.nCharCaseMap); \ +}\ +::sal_Bool SAL_CALL clazz::getCharCombineIsOn() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.bCharCombineIsOn; \ +} \ +void SAL_CALL clazz::setCharCombineIsOn(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARCOMBINEISON,the_value,varName.bCharCombineIsOn); \ +}\ +::rtl::OUString SAL_CALL clazz::getCharCombinePrefix() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sCharCombinePrefix; \ +} \ +void SAL_CALL clazz::setCharCombinePrefix(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARCOMBINEPREFIX,the_value,varName.sCharCombinePrefix); \ +}\ +::rtl::OUString SAL_CALL clazz::getCharCombineSuffix() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sCharCombineSuffix; \ +} \ +void SAL_CALL clazz::setCharCombineSuffix(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARCOMBINESUFFIX,the_value,varName.sCharCombineSuffix); \ +}\ +::sal_Bool SAL_CALL clazz::getCharHidden() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.bCharHidden; \ +} \ +void SAL_CALL clazz::setCharHidden(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARHIDDEN,the_value,varName.bCharHidden); \ +}\ +::sal_Bool SAL_CALL clazz::getCharShadowed() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.bCharShadowed; \ +} \ +void SAL_CALL clazz::setCharShadowed(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARSHADOWED,the_value,varName.bCharShadowed); \ +}\ +::sal_Bool SAL_CALL clazz::getCharContoured() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.bCharContoured; \ +} \ +void SAL_CALL clazz::setCharContoured(::sal_Bool the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_CHARCONTOURED,the_value,varName.bCharContoured); \ +}\ +::rtl::OUString SAL_CALL clazz::getHyperLinkURL() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sHyperLinkURL; \ +} \ +void SAL_CALL clazz::setHyperLinkURL(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_HYPERLINKURL,the_value,varName.sHyperLinkURL); \ +}\ +::rtl::OUString SAL_CALL clazz::getHyperLinkTarget() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sHyperLinkTarget; \ +} \ +void SAL_CALL clazz::setHyperLinkTarget(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_HYPERLINKTARGET,the_value,varName.sHyperLinkTarget); \ +}\ +::rtl::OUString SAL_CALL clazz::getHyperLinkName() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sHyperLinkName; \ +} \ +void SAL_CALL clazz::setHyperLinkName(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_HYPERLINKNAME,the_value,varName.sHyperLinkName); \ +}\ +::rtl::OUString SAL_CALL clazz::getVisitedCharStyleName() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sVisitedCharStyleName; \ +} \ +void SAL_CALL clazz::setVisitedCharStyleName(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_VISITEDCHARSTYLENAME,the_value,varName.sVisitedCharStyleName); \ +}\ +::rtl::OUString SAL_CALL clazz::getUnvisitedCharStyleName() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.sUnvisitedCharStyleName; \ +} \ +void SAL_CALL clazz::setUnvisitedCharStyleName(const ::rtl::OUString & the_value) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + set(PROPERTY_UNVISITEDCHARSTYLENAME,the_value,varName.sUnvisitedCharStyleName); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharKerning() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.nCharKerning; \ +}\ +void SAL_CALL clazz::setCharKerning(::sal_Int16 the_value) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + set(PROPERTY_CHARKERNING,the_value,varName.nCharKerning); \ +}\ +float SAL_CALL clazz::getCharHeightAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + { \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.Height; \ +}\ +void SAL_CALL clazz::setCharHeightAsian( float the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARHEIGHTASIAN,static_cast<sal_Int16>(the_value),varName.aAsianFontDescriptor.Height); \ +}\ +float SAL_CALL clazz::getCharWeightAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + { \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.Weight; \ +}\ +void SAL_CALL clazz::setCharWeightAsian( float the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARWEIGHTASIAN,the_value,varName.aAsianFontDescriptor.Weight); \ +}\ +::rtl::OUString SAL_CALL clazz::getCharFontNameAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.Name; \ +}\ +void SAL_CALL clazz::setCharFontNameAsian( const ::rtl::OUString& the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTNAMEASIAN,the_value,varName.aAsianFontDescriptor.Name); \ +}\ +::rtl::OUString SAL_CALL clazz::getCharFontStyleNameAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.StyleName; \ +}\ +void SAL_CALL clazz::setCharFontStyleNameAsian( const ::rtl::OUString& the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTSTYLENAMEASIAN,the_value,varName.aAsianFontDescriptor.StyleName); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharFontFamilyAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.Family; \ +}\ +void SAL_CALL clazz::setCharFontFamilyAsian( ::sal_Int16 the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTFAMILYASIAN,the_value,varName.aAsianFontDescriptor.Family); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharFontCharSetAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.CharSet; \ +}\ +void SAL_CALL clazz::setCharFontCharSetAsian( ::sal_Int16 the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTCHARSETASIAN,the_value,varName.aAsianFontDescriptor.CharSet); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharFontPitchAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.Pitch; \ +}\ +void SAL_CALL clazz::setCharFontPitchAsian( ::sal_Int16 the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTPITCHASIAN,the_value,varName.aAsianFontDescriptor.Pitch); \ +}\ +::com::sun::star::awt::FontSlant SAL_CALL clazz::getCharPostureAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aAsianFontDescriptor.Slant; \ +}\ +void SAL_CALL clazz::setCharPostureAsian( ::com::sun::star::awt::FontSlant the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARPOSTUREASIAN,the_value,varName.aAsianFontDescriptor.Slant); \ +}\ +::com::sun::star::lang::Locale SAL_CALL clazz::getCharLocaleAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aCharLocaleAsian; \ +}\ +void SAL_CALL clazz::setCharLocaleAsian( const ::com::sun::star::lang::Locale& the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + BoundListeners l; \ + { \ + ::osl::MutexGuard aGuard(m_aMutex); \ + if ( varName.aCharLocaleAsian.Language != the_value.Language \ + || varName.aCharLocaleAsian.Country != the_value.Country \ + || varName.aCharLocaleAsian.Variant != the_value.Variant ) \ + { \ + prepareSet(PROPERTY_CHARLOCALEASIAN, ::com::sun::star::uno::makeAny(varName.aCharLocaleAsian), ::com::sun::star::uno::makeAny(the_value), &l); \ + varName.aCharLocaleAsian = the_value; \ + } \ + } \ + l.notify(); \ +}\ +float SAL_CALL clazz::getCharHeightComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.Height; \ +}\ +void SAL_CALL clazz::setCharHeightComplex( float the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARHEIGHTCOMPLEX,static_cast<sal_Int16>(the_value),varName.aComplexFontDescriptor.Height); \ +}\ +float SAL_CALL clazz::getCharWeightComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.Weight; \ +}\ +void SAL_CALL clazz::setCharWeightComplex( float the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARWEIGHTCOMPLEX,the_value,varName.aComplexFontDescriptor.Weight); \ +}\ +::rtl::OUString SAL_CALL clazz::getCharFontNameComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.Name; \ +}\ +void SAL_CALL clazz::setCharFontNameComplex( const ::rtl::OUString& the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTNAMECOMPLEX,the_value,varName.aComplexFontDescriptor.Name); \ +}\ +::rtl::OUString SAL_CALL clazz::getCharFontStyleNameComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.StyleName; \ +}\ +void SAL_CALL clazz::setCharFontStyleNameComplex( const ::rtl::OUString& the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTSTYLENAMECOMPLEX,the_value,varName.aComplexFontDescriptor.StyleName); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharFontFamilyComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.Family; \ +}\ +void SAL_CALL clazz::setCharFontFamilyComplex( ::sal_Int16 the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTFAMILYCOMPLEX,the_value,varName.aComplexFontDescriptor.Family); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharFontCharSetComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.CharSet; \ +}\ +void SAL_CALL clazz::setCharFontCharSetComplex( ::sal_Int16 the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTCHARSETCOMPLEX,the_value,varName.aComplexFontDescriptor.CharSet); \ +}\ +::sal_Int16 SAL_CALL clazz::getCharFontPitchComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.Pitch; \ +}\ +void SAL_CALL clazz::setCharFontPitchComplex( ::sal_Int16 the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARFONTPITCHCOMPLEX,the_value,varName.aComplexFontDescriptor.Pitch); \ +}\ +::com::sun::star::awt::FontSlant SAL_CALL clazz::getCharPostureComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aComplexFontDescriptor.Slant; \ +}\ +void SAL_CALL clazz::setCharPostureComplex( ::com::sun::star::awt::FontSlant the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + set(PROPERTY_CHARPOSTURECOMPLEX,the_value,varName.aComplexFontDescriptor.Slant); \ +}\ +::com::sun::star::lang::Locale SAL_CALL clazz::getCharLocaleComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + ::osl::MutexGuard aGuard(m_aMutex); \ + return varName.aCharLocaleComplex; \ +}\ +void SAL_CALL clazz::setCharLocaleComplex( const ::com::sun::star::lang::Locale& the_value ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ +{ \ + BoundListeners l; \ + { \ + ::osl::MutexGuard aGuard(m_aMutex); \ + if ( varName.aCharLocaleComplex.Language != the_value.Language \ + || varName.aCharLocaleComplex.Country != the_value.Country \ + || varName.aCharLocaleComplex.Variant != the_value.Variant ) \ + { \ + prepareSet(PROPERTY_CHARLOCALECOMPLEX, ::com::sun::star::uno::makeAny(varName.aCharLocaleComplex), ::com::sun::star::uno::makeAny(the_value), &l); \ + varName.aCharLocaleComplex = the_value; \ + } \ + } \ + l.notify(); \ +}\ + + +#define NO_REPORTCONTROLFORMAT_IMPL(clazz) \ +sal_Int16 SAL_CALL clazz::getParaAdjust() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +void SAL_CALL clazz::setParaAdjust(sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int16 SAL_CALL clazz::getCharStrikeout() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +void SAL_CALL clazz::setCharStrikeout(::sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharWordMode() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +void SAL_CALL clazz::setCharWordMode(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int16 SAL_CALL clazz::getCharRotation() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +void SAL_CALL clazz::setCharRotation(::sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int16 SAL_CALL clazz::getCharScaleWidth() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +void SAL_CALL clazz::setCharScaleWidth(::sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharFlash() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharFlash(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharAutoKerning() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharAutoKerning(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int8 SAL_CALL clazz::getCharEscapementHeight() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharEscapementHeight(::sal_Int8 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +lang::Locale SAL_CALL clazz::getCharLocale() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharLocale(const lang::Locale & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int16 SAL_CALL clazz::getCharEscapement() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharEscapement(::sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int16 SAL_CALL clazz::getCharCaseMap() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharCaseMap(::sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharCombineIsOn() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharCombineIsOn(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::rtl::OUString SAL_CALL clazz::getCharCombinePrefix() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharCombinePrefix(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::rtl::OUString SAL_CALL clazz::getCharCombineSuffix() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharCombineSuffix(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharHidden() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharHidden(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharShadowed() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharShadowed(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Bool SAL_CALL clazz::getCharContoured() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setCharContoured(::sal_Bool /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::rtl::OUString SAL_CALL clazz::getVisitedCharStyleName() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setVisitedCharStyleName(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::rtl::OUString SAL_CALL clazz::getUnvisitedCharStyleName() throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +} \ +void SAL_CALL clazz::setUnvisitedCharStyleName(const ::rtl::OUString & /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException) \ +{ \ + throw beans::UnknownPropertyException();\ +}\ +::sal_Int16 SAL_CALL clazz::getCharKerning() throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + throw beans::UnknownPropertyException();\ +}\ +void SAL_CALL clazz::setCharKerning(::sal_Int16 /*the_value*/) throw (uno::RuntimeException, beans::UnknownPropertyException)\ +{ \ + throw beans::UnknownPropertyException();\ +}\ +\ +awt::FontDescriptor SAL_CALL clazz::getFontDescriptor() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setFontDescriptor( const awt::FontDescriptor& /*_fontdescriptor*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +awt::FontDescriptor SAL_CALL clazz::getFontDescriptorAsian() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setFontDescriptorAsian( const awt::FontDescriptor& /*_fontdescriptor*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +awt::FontDescriptor SAL_CALL clazz::getFontDescriptorComplex() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ +throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setFontDescriptorComplex( const awt::FontDescriptor& /*_fontdescriptor*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ +throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getControlTextEmphasis() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setControlTextEmphasis( ::sal_Int16 /*_fontemphasismark*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getCharRelief() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharRelief( ::sal_Int16 /*_fontrelief*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int32 SAL_CALL clazz::getCharColor() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharColor( ::sal_Int32 /*_textcolor*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int32 SAL_CALL clazz::getCharUnderlineColor() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharUnderlineColor( ::sal_Int32 /*_textlinecolor*/ ) throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +style::VerticalAlignment SAL_CALL clazz::getVerticalAlign() throw (beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + ::osl::MutexGuard aGuard(m_aMutex);\ + return m_aProps.aFormatProperties.aVerticalAlignment;\ +}\ +\ +void SAL_CALL clazz::setVerticalAlign( style::VerticalAlignment _verticalalign ) throw (lang::IllegalArgumentException,beans::UnknownPropertyException,uno::RuntimeException)\ +{\ + set(PROPERTY_VERTICALALIGN,_verticalalign,m_aProps.aFormatProperties.aVerticalAlignment);\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getCharEmphasis() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharEmphasis( ::sal_Int16 /*_charemphasis*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::rtl::OUString SAL_CALL clazz::getCharFontName() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharFontName( const ::rtl::OUString& /*_charfontname*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::rtl::OUString SAL_CALL clazz::getCharFontStyleName() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharFontStyleName( const ::rtl::OUString& /*_charfontstylename*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getCharFontFamily() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharFontFamily( ::sal_Int16 /*_charfontfamily*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getCharFontCharSet() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharFontCharSet( ::sal_Int16 /*_charfontcharset*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getCharFontPitch() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharFontPitch( ::sal_Int16 /*_charfontpitch*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +float SAL_CALL clazz::getCharHeight() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharHeight( float /*_charheight*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +::sal_Int16 SAL_CALL clazz::getCharUnderline() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharUnderline( ::sal_Int16 /*_charunderline*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +float SAL_CALL clazz::getCharWeight() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharWeight( float /*_charweight*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +awt::FontSlant SAL_CALL clazz::getCharPosture() throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ +\ +void SAL_CALL clazz::setCharPosture( awt::FontSlant /*_charposture*/ ) throw (beans::UnknownPropertyException, uno::RuntimeException)\ +{\ + throw beans::UnknownPropertyException();\ +}\ + float SAL_CALL clazz::getCharHeightAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharHeightAsian( float ) throw (beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + float SAL_CALL clazz::getCharWeightAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharWeightAsian( float ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::rtl::OUString SAL_CALL clazz::getCharFontNameAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontNameAsian( const ::rtl::OUString& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::rtl::OUString SAL_CALL clazz::getCharFontStyleNameAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontStyleNameAsian( const ::rtl::OUString& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::sal_Int16 SAL_CALL clazz::getCharFontFamilyAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontFamilyAsian( ::sal_Int16 ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::sal_Int16 SAL_CALL clazz::getCharFontCharSetAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontCharSetAsian( ::sal_Int16 ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::sal_Int16 SAL_CALL clazz::getCharFontPitchAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontPitchAsian( ::sal_Int16 ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::com::sun::star::awt::FontSlant SAL_CALL clazz::getCharPostureAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharPostureAsian( ::com::sun::star::awt::FontSlant ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::com::sun::star::lang::Locale SAL_CALL clazz::getCharLocaleAsian() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharLocaleAsian( const ::com::sun::star::lang::Locale& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + float SAL_CALL clazz::getCharHeightComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharHeightComplex( float ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + float SAL_CALL clazz::getCharWeightComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharWeightComplex( float ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::rtl::OUString SAL_CALL clazz::getCharFontNameComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontNameComplex( const ::rtl::OUString& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::rtl::OUString SAL_CALL clazz::getCharFontStyleNameComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontStyleNameComplex( const ::rtl::OUString& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::sal_Int16 SAL_CALL clazz::getCharFontFamilyComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontFamilyComplex( ::sal_Int16 ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::sal_Int16 SAL_CALL clazz::getCharFontCharSetComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontCharSetComplex( ::sal_Int16 ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::sal_Int16 SAL_CALL clazz::getCharFontPitchComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharFontPitchComplex( ::sal_Int16 ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::com::sun::star::awt::FontSlant SAL_CALL clazz::getCharPostureComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharPostureComplex( ::com::sun::star::awt::FontSlant ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + ::com::sun::star::lang::Locale SAL_CALL clazz::getCharLocaleComplex() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +}\ + void SAL_CALL clazz::setCharLocaleComplex( const ::com::sun::star::lang::Locale& ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)\ + {\ + throw beans::UnknownPropertyException();\ +} + + +// ::com::sun::star::report::XReportControlFormat: +#define REPORTCONTROLFORMAT_IMPL(clazz,varName) \ + REPORTCONTROLFORMAT_IMPL1(clazz,varName) \ + REPORTCONTROLFORMAT_IMPL2(clazz,varName) + + +#endif //INCLUDED_REPORTHELPERIMPL_HXX + diff --git a/reportdesign/source/core/inc/ReportUndoFactory.hxx b/reportdesign/source/core/inc/ReportUndoFactory.hxx new file mode 100644 index 000000000000..5e2a70f3ae19 --- /dev/null +++ b/reportdesign/source/core/inc/ReportUndoFactory.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORT_UNDOFACTORY_HXX_INCLUDED +#define REPORT_UNDOFACTORY_HXX_INCLUDED + +#include <svx/svdundo.hxx> +#include <memory> +#include "ModuleHelper.hxx" + +namespace rptui +{ + class OReportUndoFactory : public SdrUndoFactory + { + OModuleClient m_aModuleClient; + ::std::auto_ptr<SdrUndoFactory> m_pUndoFactory; + + OReportUndoFactory(const OReportUndoFactory&); + OReportUndoFactory& operator=(const OReportUndoFactory&); + public: + OReportUndoFactory(); + virtual ~OReportUndoFactory(); + + // shapes + virtual SdrUndoAction* CreateUndoMoveObject( SdrObject& rObject ); + virtual SdrUndoAction* CreateUndoMoveObject( SdrObject& rObject, const Size& rDist ); + virtual SdrUndoAction* CreateUndoGeoObject( SdrObject& rObject ); + virtual SdrUndoAction* CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1 = false, bool bSaveText = false ); + virtual SdrUndoAction* CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect = false); + virtual SdrUndoAction* CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect = false); + virtual SdrUndoAction* CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false); + virtual SdrUndoAction* CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect = false); + virtual SdrUndoAction* CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect = false); + + virtual SdrUndoAction* CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1); + + virtual SdrUndoAction* CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect = false ); + virtual SdrUndoAction* CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer ); + virtual SdrUndoAction* CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ); + + // layer + virtual SdrUndoAction* CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel); + virtual SdrUndoAction* CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel); + virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1); + + // page + virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage); + virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage); + virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage); + virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1); + + // master page + virtual SdrUndoAction* CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage); + virtual SdrUndoAction* CreateUndoPageChangeMasterPage(SdrPage& rChangedPage); + + }; +//============================================================================== +} // rptui +//============================================================================== + +#endif // REPORT_UNDOFACTORY_HXX_INCLUDED + diff --git a/reportdesign/source/core/inc/RptObjectListener.hxx b/reportdesign/source/core/inc/RptObjectListener.hxx new file mode 100644 index 000000000000..0a781ee36c61 --- /dev/null +++ b/reportdesign/source/core/inc/RptObjectListener.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _REPORT_RPTUILIST_HXX +#define _REPORT_RPTUILIST_HXX + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/container/XContainerListener.hpp> + +namespace rptui +{ +class OObjectBase; + +//============================================================================ +// OObjectListener +//============================================================================ + +typedef ::cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener > TPropertyChangeListenerHelper; + +class OObjectListener: public TPropertyChangeListenerHelper +{ +private: + OObjectBase* m_pObject; + OObjectListener(const OObjectListener&); + void operator =(const OObjectListener&); +protected: + virtual ~OObjectListener(); +public: + OObjectListener(OObjectBase* _pObject); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); +}; +} +#endif // _REPORT_RPTUILIST_HXX diff --git a/reportdesign/source/core/inc/Section.hxx b/reportdesign/source/core/inc/Section.hxx new file mode 100644 index 000000000000..3d3f0f205b06 --- /dev/null +++ b/reportdesign/source/core/inc/Section.hxx @@ -0,0 +1,208 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_API_SECTION_HXX +#define REPORTDESIGN_API_SECTION_HXX + +#include <com/sun/star/report/XSection.hpp> +#include <cppuhelper/compbase3.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/uno3.hxx> +#include <comphelper/types.hxx> +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <comphelper/stl_types.hxx> +#include <comphelper/implementationreference.hxx> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace reportdesign +{ + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::report::XSection + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XUnoTunnel> SectionBase; + typedef ::cppu::PropertySetMixin<com::sun::star::report::XSection> SectionPropertySet; + + class OSection : public comphelper::OMutexAndBroadcastHelper, + public SectionBase, + public SectionPropertySet + { + ::cppu::OInterfaceContainerHelper m_aContainerListeners; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xDrawPage; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxy; + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XGroup > m_xGroup; + ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XReportDefinition > m_xReportDefinition; + ::rtl::OUString m_sName; + ::rtl::OUString m_sConditionalPrintExpression; + ::sal_uInt32 m_nHeight; + ::sal_Int32 m_nBackgroundColor; + ::sal_Int16 m_nForceNewPage; + ::sal_Int16 m_nNewRowOrCol; + ::sal_Bool m_bKeepTogether; + ::sal_Bool m_bCanGrow; + ::sal_Bool m_bCanShrink; + ::sal_Bool m_bRepeatSection; + ::sal_Bool m_bVisible; + ::sal_Bool m_bBacktransparent; + bool m_bInRemoveNotify; + bool m_bInInsertNotify; + + private: + OSection(const OSection&); + OSection& operator=(const OSection&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( _member != _Value ) + { + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + } + l.notify(); + } + + /** checks if this section is eiter the page header or footer and if so it throws an UnknownPropertyException + * + */ + void checkNotPageHeaderFooter(); + + void init(); + protected: + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual ~OSection(); + + /** this function is called upon disposing the component + */ + // TODO: VirtualFunctionFinder: This is virtual function! + // + virtual void SAL_CALL disposing(); + public: + typedef ::comphelper::ImplementationReference< OSection ,::com::sun::star::report::XSection,::com::sun::star::uno::XWeak > TSection; + + OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xParent + ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context,bool _bPageSection=false); + OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xParent + ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context,bool _bPageSection=false); + + DECLARE_XINTERFACE( ) + + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XSection + virtual ::sal_Bool SAL_CALL getVisible() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& _name ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_uInt32 SAL_CALL getHeight() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHeight( ::sal_uInt32 _height ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getBackColor() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBackColor( ::sal_Int32 _backgroundcolor ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getBackTransparent() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBackTransparent( ::sal_Bool _backtransparent ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getConditionalPrintExpression() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getForceNewPage() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setForceNewPage( ::sal_Int16 _forcenewpage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getNewRowOrCol() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setNewRowOrCol( ::sal_Int16 _newroworcol ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getKeepTogether() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setKeepTogether( ::sal_Bool _keeptogether ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getCanGrow() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCanGrow( ::sal_Bool _cangrow ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getCanShrink() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCanShrink( ::sal_Bool _canshrink ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getRepeatSection() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRepeatSection( ::sal_Bool _repeatsection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > SAL_CALL getGroup() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > SAL_CALL getReportDefinition() throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > SAL_CALL createReportComponent( const ::rtl::OUString& _sReportComponentSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::lang::IllegalArgumentException,::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableReportComponentNames( ) throw (::com::sun::star::uno::RuntimeException); + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + // XShapes + virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException); + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static OSection* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + static void lcl_copySection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSource + ,::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xDest); + + void notifyElementAdded(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape); + void notifyElementRemoved(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape); + }; +} +#endif //REPORTDESIGN_API_SECTION_HXX diff --git a/reportdesign/source/core/inc/Shape.hxx b/reportdesign/source/core/inc/Shape.hxx new file mode 100644 index 000000000000..00a351f544b5 --- /dev/null +++ b/reportdesign/source/core/inc/Shape.hxx @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPT_SHAPE_HXX +#define RPT_SHAPE_HXX + +#include <cppuhelper/propertysetmixin.hxx> +#include <com/sun/star/report/XShape.hpp> +#include "ReportControlModel.hxx" +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ReportHelperDefines.hxx" +#include <comphelper/propagg.hxx> +#include <memory> + +namespace reportdesign +{ + typedef ::cppu::PropertySetMixin< com::sun::star::report::XShape > ShapePropertySet; + typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XShape + ,com::sun::star::lang::XServiceInfo > ShapeBase; + + /** \class OShape Defines the implementation of a \interface com:::sun::star::report::XShape + * \ingroup reportdesign_api + * + */ + class OShape : public comphelper::OBaseMutex, + public ShapeBase, + public ShapePropertySet + { + friend class OShapeHelper; + ::std::auto_ptr< ::comphelper::OPropertyArrayAggregationHelper> m_pAggHelper; + OReportControlModel m_aProps; + com::sun::star::drawing::HomogenMatrix3 m_Transformation; + ::sal_Int32 m_nZOrder; + ::sal_Bool m_bOpaque; + + ::rtl::OUString m_sServiceName; + ::rtl::OUString m_CustomShapeEngine; + ::rtl::OUString m_CustomShapeData; + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > + m_CustomShapeGeometry; + + private: + OShape(const OShape&); + OShape& operator=(const OShape&); + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + l.notify(); + } + void checkIndex(sal_Int32 _nIndex); + cppu::IPropertyArrayHelper& getInfoHelper(); + protected: + virtual ~OShape(); + public: + explicit OShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); + explicit OShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _xFactory + ,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape + ,const ::rtl::OUString& _sServiceName); + + DECLARE_XINTERFACE( ) + // ::com::sun::star::lang::XServiceInfo + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XReportComponent + REPORTCOMPONENT_HEADER() + + // XShape + SHAPE_HEADER() + + virtual ::rtl::OUString SAL_CALL getCustomShapeEngine() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCustomShapeEngine( const ::rtl::OUString& _customshapeengine ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCustomShapeData() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCustomShapeData( const ::rtl::OUString& _customshapedata ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCustomShapeGeometry() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCustomShapeGeometry( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _customshapegeometry ) throw (::com::sun::star::uno::RuntimeException); + + virtual ::sal_Bool SAL_CALL getOpaque() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setOpaque( ::sal_Bool _opaque ) throw (::com::sun::star::uno::RuntimeException); + + // XShapeDescriptor + virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException); + + // XReportControlModel + REPORTCONTROLMODEL_HEADER() + + // XReportControlFormat + REPORTCONTROLFORMAT_HEADER() + // XShape + virtual ::sal_Int32 SAL_CALL getZOrder() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setZOrder( ::sal_Int32 _zorder ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::drawing::HomogenMatrix3 SAL_CALL getTransformation() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransformation( const ::com::sun::star::drawing::HomogenMatrix3& _transformation ) throw (::com::sun::star::uno::RuntimeException); + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::addEventListener(aListener); + } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) + { + cppu::WeakComponentImplHelperBase::removeEventListener(aListener); + } + + // XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif //RPT_SHAPE_HXX + diff --git a/reportdesign/source/core/inc/Tools.hxx b/reportdesign/source/core/inc/Tools.hxx new file mode 100644 index 000000000000..e8753078bf97 --- /dev/null +++ b/reportdesign/source/core/inc/Tools.hxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_TOOLS_HXX +#define REPORTDESIGN_TOOLS_HXX + +#include <com/sun/star/report/XReportDefinition.hpp> +#include <com/sun/star/report/XSection.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/report/XFixedText.hpp> +#include <com/sun/star/report/XFormattedField.hpp> + + +#include "Section.hxx" +#include "corestrings.hrc" + +namespace reportdesign +{ + template <class T> void lcl_createSectionIfNeeded(sal_Bool _bOn,const T& _xParent,::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection/*in/out*/,bool _bPageSection = false) + { + if ( _bOn && !_xSection.is() ) + _xSection = new OSection(_xParent,_xParent->getContext(),_bPageSection); + else if ( !_bOn ) + //_xSection.clear(); + ::comphelper::disposeComponent(_xSection); + } + + /** gets the properties which should be removed form the property set implementation. + * + * \return A sequence of all properties which should be removed for none char able implementations. + */ + ::com::sun::star::uno::Sequence< ::rtl::OUString > lcl_getCharOptionals(); + + /** uses the XChild interface to get the section from any child of it. + * + * \param _xReportComponent A report component which is a child of the section. + * \return The sectin where this report component resists in. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> lcl_getSection(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xReportComponent); + + /** throws an illegal argument exception. The message text is the resource RID_STR_ERROR_WRONG_ARGUMENT + the type as reference. + * + * \param _sTypeName The reference where to look for the correct values. + * \param ExceptionContext_ The exception context. + * \param ArgumentPosition_ The argument position. + * \param Context_ The context to get the factory service. + */ + void throwIllegallArgumentException(const ::rtl::OUString& _sTypeName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& ExceptionContext_ + ,const ::sal_Int16& ArgumentPosition_ + ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context_); + + /** clones the given object + * + * \param _xReportComponent the object to be cloned + * \param _xFactory the factory to create the clone + * \param _sServiceName the service of the to be cloned object + * \return the clone + */ + ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > cloneObject( + const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xReportComponent + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xFactory + ,const ::rtl::OUString& _sServiceName); + + class OShapeHelper + { + public: + template<typename T> static void setSize(const ::com::sun::star::awt::Size& aSize,T* _pShape) + { + OSL_ENSURE(aSize.Width >= 0 && aSize.Height >= 0,"Illegal with or height!"); + + ::osl::MutexGuard aGuard(_pShape->m_aMutex); + if ( _pShape->m_aProps.aComponent.m_xShape.is() ) + { + ::com::sun::star::awt::Size aOldSize = _pShape->m_aProps.aComponent.m_xShape->getSize(); + if ( aOldSize.Height != aSize.Height || aOldSize.Width != aSize.Width ) + { + _pShape->m_aProps.aComponent.m_nWidth = aOldSize.Width; + _pShape->m_aProps.aComponent.m_nHeight = aOldSize.Height; + _pShape->m_aProps.aComponent.m_xShape->setSize(aSize); + } + } + _pShape->set(PROPERTY_WIDTH,aSize.Width,_pShape->m_aProps.aComponent.m_nWidth); + _pShape->set(PROPERTY_HEIGHT,aSize.Height,_pShape->m_aProps.aComponent.m_nHeight); + } + template<typename T> static ::com::sun::star::awt::Size getSize( T* _pShape ) + { + ::osl::MutexGuard aGuard(_pShape->m_aMutex); + if ( _pShape->m_aProps.aComponent.m_xShape.is() ) + { + ::com::sun::star::awt::Size aSize = _pShape->m_aProps.aComponent.m_xShape->getSize(); + OSL_ENSURE(aSize.Width >= 0 && aSize.Height >= 0,"Illegal with or height!"); + return aSize; + } + return ::com::sun::star::awt::Size(_pShape->m_aProps.aComponent.m_nWidth,_pShape->m_aProps.aComponent.m_nHeight); + } + + template<typename T> static void setPosition( const ::com::sun::star::awt::Point& _aPosition ,T* _pShape) + { + // we know it is not allowed that the position in smaller 0, but in NbcMove() it will handled right. + // only at 'Undo' it is possible to short set the position smaller 0 + // OSL_ENSURE(_aPosition.X >= 0 && _aPosition.Y >= 0,"set to Illegal position!"); + ::osl::MutexGuard aGuard(_pShape->m_aMutex); + ::com::sun::star::awt::Point aOldPos; + aOldPos.X = _pShape->m_aProps.aComponent.m_nPosX; + aOldPos.Y = _pShape->m_aProps.aComponent.m_nPosY; + + ::com::sun::star::awt::Point aPosition(_aPosition); + if ( _pShape->m_aProps.aComponent.m_xShape.is() ) + { + aOldPos = _pShape->m_aProps.aComponent.m_xShape->getPosition(); + if ( aOldPos.X != aPosition.X || aOldPos.Y != aPosition.Y ) + { + _pShape->m_aProps.aComponent.m_nPosX = aOldPos.X; + _pShape->m_aProps.aComponent.m_nPosY = aOldPos.Y; + _pShape->m_aProps.aComponent.m_xShape->setPosition(aPosition); + } + } + _pShape->set(PROPERTY_POSITIONX,aPosition.X,aOldPos.X); + _pShape->set(PROPERTY_POSITIONY,aPosition.Y,aOldPos.Y); + } + template<typename T> static ::com::sun::star::awt::Point getPosition(T* _pShape) + { + ::osl::MutexGuard aGuard(_pShape->m_aMutex); + if ( _pShape->m_aProps.aComponent.m_xShape.is() ) + { + ::com::sun::star::awt::Point aPosition = _pShape->m_aProps.aComponent.m_xShape->getPosition(); +// OSL_ENSURE(aPosition.X >= 0 && aPosition.Y >= 0,"Illegal position!"); + return aPosition; + } + return ::com::sun::star::awt::Point(_pShape->m_aProps.aComponent.m_nPosX,_pShape->m_aProps.aComponent.m_nPosY); + } + template<typename T> static void setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& Parent, T* _pShape) + { + ::osl::MutexGuard aGuard(_pShape->m_aMutex); + _pShape->m_aProps.aComponent.m_xParent = ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild >(Parent,::com::sun::star::uno::UNO_QUERY); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xChild; + comphelper::query_aggregation(_pShape->m_aProps.aComponent.m_xProxy,xChild); + if ( xChild.is() ) + xChild->setParent(Parent); + } + template<typename T> static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > getParent( T* _pShape ) + { + ::osl::MutexGuard aGuard(_pShape->m_aMutex); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xChild; + comphelper::query_aggregation(_pShape->m_aProps.aComponent.m_xProxy,xChild); + if ( xChild.is() ) + return xChild->getParent(); + return _pShape->m_aProps.aComponent.m_xParent; + } + }; +// ============================================================================= +} // namespace reportdesign +// ============================================================================= +#endif // REPORTDESIGN_TOOLS_HXX + diff --git a/reportdesign/source/core/inc/conditionupdater.hxx b/reportdesign/source/core/inc/conditionupdater.hxx new file mode 100644 index 000000000000..6db89dcc6386 --- /dev/null +++ b/reportdesign/source/core/inc/conditionupdater.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CONDITIONUPDATER_HXX +#define CONDITIONUPDATER_HXX + +#include "conditionalexpression.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/report/XReportControlModel.hpp> +/** === end UNO includes === **/ + +#include <boost/noncopyable.hpp> + +//........................................................................ +namespace rptui +{ +//........................................................................ + + //==================================================================== + //= ConditionUpdater + //==================================================================== + class ConditionUpdater : public ::boost::noncopyable + { + public: + ConditionUpdater(); + ~ConditionUpdater(); + + /// notifies the object about the change of a property value, somewhere in the report definition + void notifyPropertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ); + + private: + /// does late initializations, return whether or not successful + bool impl_lateInit_nothrow(); + + void impl_adjustFormatConditions_nothrow( + const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel >& _rxRptControlModel, + const ::rtl::OUString& _rOldDataSource, + const ::rtl::OUString& _rNewDataSource + ); + + private: + ConditionalExpressions m_aConditionalExpressions; + }; + +//........................................................................ +} // namespace rptui +//........................................................................ + +#endif // CONDITIONUPDATER_HXX diff --git a/reportdesign/source/core/inc/core_resource.hrc b/reportdesign/source/core/inc/core_resource.hrc new file mode 100644 index 000000000000..e565ddc9b9c5 --- /dev/null +++ b/reportdesign/source/core/inc/core_resource.hrc @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef REPORTDESIGN_CORE_RESOURCE_HRC_ +#define REPORTDESIGN_CORE_RESOURCE_HRC_ + +#ifndef _SOLAR_HRC +#include <svl/solar.hrc> +#endif + +//------------------------------------------------------------------------------ +#define RID_CORE_STRINGS_START RID_RPT_START + +//------------------------------------------------------------------------------ +//- String-IDs +#define RID_STR_DETAIL ( RID_CORE_STRINGS_START + 0 ) +#define RID_STR_PAGE_HEADER ( RID_CORE_STRINGS_START + 1 ) +#define RID_STR_PAGE_FOOTER ( RID_CORE_STRINGS_START + 2 ) +#define RID_STR_REPORT_HEADER ( RID_CORE_STRINGS_START + 3 ) +#define RID_STR_REPORT_FOOTER ( RID_CORE_STRINGS_START + 4 ) +#define RID_STR_PROPERTY_CHANGE_NOT_ALLOWED ( RID_CORE_STRINGS_START + 5 ) +#define RID_STR_ERROR_WRONG_ARGUMENT ( RID_CORE_STRINGS_START + 6 ) +#define RID_STR_ARGUMENT_IS_NULL ( RID_CORE_STRINGS_START + 7 ) +#define RID_STR_SHAPE ( RID_CORE_STRINGS_START + 8 ) +#define RID_STR_REPORT ( RID_CORE_STRINGS_START + 9 ) +#define RID_STR_IMAGECONTROL ( RID_CORE_STRINGS_START + 10 ) +#define RID_STR_FIXEDTEXT ( RID_CORE_STRINGS_START + 11 ) +#define RID_STR_FORMATTEDFIELD ( RID_CORE_STRINGS_START + 12 ) +#define RID_STR_GROUP_HEADER ( RID_CORE_STRINGS_START + 13 ) +#define RID_STR_GROUP_FOOTER ( RID_CORE_STRINGS_START + 14 ) +#define RID_STR_FIXEDLINE ( RID_CORE_STRINGS_START + 15 ) + + +#endif // REPORTDESIGN_CORE_RESOURCE_HRC_ + diff --git a/reportdesign/source/core/inc/core_resource.hxx b/reportdesign/source/core/inc/core_resource.hxx new file mode 100644 index 000000000000..36e3e3149404 --- /dev/null +++ b/reportdesign/source/core/inc/core_resource.hxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef REPORTDESIGN_CORE_RESOURCE_HXX_ +#define REPORTDESIGN_CORE_RESOURCE_HXX_ + + +#include <rtl/ustring.hxx> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> + +class SimpleResMgr; +//......................................................................... +namespace reportdesign +{ + +#define RPT_RESSTRING(id,_rM) ResourceManager::loadString(id,_rM) + + //================================================================== + //= ResourceManager + //= handling ressources within the DBA-Core library + //================================================================== + class ResourceManager + { + static SimpleResMgr* m_pImpl; + + private: + // no instantiation allowed + ResourceManager() { } + ~ResourceManager() { } + + // we'll instantiate one static member of the following class, which, in it's dtor, + // ensures that m_pImpl will be deleted + class EnsureDelete + { + public: + EnsureDelete() { } + ~EnsureDelete(); + }; + friend class EnsureDelete; + + protected: + static void ensureImplExists(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory >& _rM); + + public: + /** loads the string with the specified resource id from the FormLayer resource file + */ + static ::rtl::OUString loadString(sal_uInt16 _nResId,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory >& _rM); + }; + +//......................................................................... +} +//......................................................................... + +#endif // REPORTDESIGN_CORE_RESOURCE_HXX_ + diff --git a/reportdesign/source/core/misc/conditionalexpression.cxx b/reportdesign/source/core/misc/conditionalexpression.cxx new file mode 100644 index 000000000000..8537f6b81d50 --- /dev/null +++ b/reportdesign/source/core/misc/conditionalexpression.cxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "conditionalexpression.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//........................................................................ +namespace rptui +{ +//........................................................................ + + /** === begin UNO using === **/ + /** === end UNO using === **/ + + // ============================================================================= + // = ConditionalExpression + // ============================================================================= + // ----------------------------------------------------------------------------- + ConditionalExpression::ConditionalExpression( const sal_Char* _pAsciiPattern ) + :m_sPattern( ::rtl::OUString::createFromAscii( _pAsciiPattern ) ) + { + } + + // ----------------------------------------------------------------------------- + ::rtl::OUString ConditionalExpression::assembleExpression( const ::rtl::OUString& _rFieldDataSource, const ::rtl::OUString& _rLHS, const ::rtl::OUString& _rRHS ) const + { + ::rtl::OUString sExpression( m_sPattern ); + + sal_Int32 nPatternIndex = sExpression.indexOf( '$' ); + while ( nPatternIndex > -1 ) + { + const ::rtl::OUString* pReplace = NULL; + switch ( sExpression.getStr()[ nPatternIndex + 1 ] ) + { + case '$': pReplace = &_rFieldDataSource; break; + case '1': pReplace = &_rLHS; break; + case '2': pReplace = &_rRHS; break; + default: break; + } + + if ( pReplace == NULL ) + { + OSL_ENSURE( false, "ConditionalExpression::assembleExpression: illegal pattern!" ); + break; + } + + sExpression = sExpression.replaceAt( nPatternIndex, 2, *pReplace ); + nPatternIndex = sExpression.indexOf( '$', nPatternIndex + pReplace->getLength() + 1 ); + } + return sExpression; + } + + // ----------------------------------------------------------------------------- + bool ConditionalExpression::matchExpression( const ::rtl::OUString& _rExpression, const ::rtl::OUString& _rFieldDataSource, ::rtl::OUString& _out_rLHS, ::rtl::OUString& _out_rRHS ) const + { + (void)_rExpression; + (void)_rFieldDataSource; + (void)_out_rLHS; + (void)_out_rRHS; + + // if we had regular expression, the matching would be pretty easy ... + // just replace $1 and $2 in the pattern with (.*), and then get them with \1 resp. \2. + // Unfortunately, we don't have such a regexp engine ... + + // Okay, let's start with replacing all $$ in our pattern with the actual field data source + ::rtl::OUString sMatchExpression( m_sPattern ); + const ::rtl::OUString sFieldDataPattern( RTL_CONSTASCII_USTRINGPARAM( "$$" ) ); + sal_Int32 nIndex( sMatchExpression.indexOf( sFieldDataPattern ) ); + while ( nIndex != -1 ) + { + sMatchExpression = sMatchExpression.replaceAt( nIndex, sFieldDataPattern.getLength(), _rFieldDataSource ); + nIndex = sMatchExpression.indexOf( sFieldDataPattern, nIndex + _rFieldDataSource.getLength() ); + } + + const ::rtl::OUString sLHSPattern( RTL_CONSTASCII_USTRINGPARAM( "$1" ) ); + const ::rtl::OUString sRHSPattern( RTL_CONSTASCII_USTRINGPARAM( "$2" ) ); + sal_Int32 nLHSIndex( sMatchExpression.indexOf( sLHSPattern ) ); + sal_Int32 nRHSIndex( sMatchExpression.indexOf( sRHSPattern ) ); + + // now we should have at most one occurance of $1 and $2, resp. + OSL_ENSURE( sMatchExpression.indexOf( sLHSPattern, nLHSIndex + 1 ) == -1, + "ConditionalExpression::matchExpression: unsupported pattern (more than one LHS occurance)!" ); + OSL_ENSURE( sMatchExpression.indexOf( sRHSPattern, nRHSIndex + 1 ) == -1, + "ConditionalExpression::matchExpression: unsupported pattern (more than one RHS occurance)!" ); + // Also, an LHS must be present, and precede the RHS (if present) + OSL_ENSURE( ( nLHSIndex != -1 ) && ( ( nLHSIndex < nRHSIndex ) || ( nRHSIndex == -1 ) ), + "ConditionalExpression::matchExpression: no LHS, or an RHS preceeding the LHS - this is not supported!" ); + + // up to the occurance of the LHS (which must exist, see above), the two expressions + // must be identical + if ( _rExpression.getLength() < nLHSIndex ) + return false; + const ::rtl::OUString sExprPart1( _rExpression.copy( 0, nLHSIndex ) ); + const ::rtl::OUString sMatchExprPart1( sMatchExpression.copy( 0, nLHSIndex ) ); + if ( sExprPart1 != sMatchExprPart1 ) + // the left-most expression parts do not match + return false; + + // after the occurance of the RHS (or the LHS, if there is no RHS), the two expressions + // must be identical, too + bool bHaveRHS( nRHSIndex != -1 ); + sal_Int32 nRightMostIndex( bHaveRHS ? nRHSIndex : nLHSIndex ); + const ::rtl::OUString sMatchExprPart3( sMatchExpression.copy( nRightMostIndex + 2 ) ); + if ( _rExpression.getLength() < sMatchExprPart3.getLength() ) + // the expression is not even long enough to hold the right-most part of the match expression + return false; + const ::rtl::OUString sExprPart3( _rExpression.copy( _rExpression.getLength() - sMatchExprPart3.getLength() ) ); + if ( sExprPart3 != sMatchExprPart3 ) + // the right-most expression parts do not match + return false; + + // if we don't have an RHS, we're done + if ( !bHaveRHS ) + { + _out_rLHS = _rExpression.copy( sExprPart1.getLength(), _rExpression.getLength() - sExprPart1.getLength() - sExprPart3.getLength() ); + return true; + } + + // strip the match expression by its right-most and left-most part, and by the placeholders $1 and $2 + sal_Int32 nMatchExprPart2Start( nLHSIndex + sLHSPattern.getLength() ); + ::rtl::OUString sMatchExprPart2 = sMatchExpression.copy( + nMatchExprPart2Start, + sMatchExpression.getLength() - nMatchExprPart2Start - sMatchExprPart3.getLength() - 2 + ); + // strip the expression by its left-most and right-most part + const ::rtl::OUString sExpression( _rExpression.copy( + sExprPart1.getLength(), + _rExpression.getLength() - sExprPart1.getLength() - sExprPart3.getLength() + ) ); + + sal_Int32 nPart2Index = sExpression.indexOf( sMatchExprPart2 ); + if ( nPart2Index == -1 ) + // the "middle" part of the match expression does not exist in the expression at all + return false; + + OSL_ENSURE( sExpression.indexOf( sMatchExprPart2, nPart2Index + 1 ) == -1, + "ConditionalExpression::matchExpression: ambiguous matching!" ); + // if this fires, then we're lost: The middle part exists two times in the expression, + // so we cannot reliably determine what's the LHS and what's the RHS. + // Well, the whole mechanism is flawed, anyway: + // Encoding the field content in the conditional expression will break as soon + // as somebody + // - assigns a Data Field to a control + // - creates a conditional format expression for the control + // - assigns another Data Field to the control + // - opens the Conditional Format Dialog, again + // Here, at the latest, you can see that we need another mechanism, anyway, which does not + // rely on those strange expression building/matching + + _out_rLHS = sExpression.copy( 0, nPart2Index ); + _out_rRHS = sExpression.copy( nPart2Index + sMatchExprPart2.getLength() ); + + return true; + } + + // ============================================================================= + // = ConditionalExpressionFactory + // ============================================================================= + // ----------------------------------------------------------------------------- + size_t ConditionalExpressionFactory::getKnownConditionalExpressions( ConditionalExpressions& _out_rCondExp ) + { + ConditionalExpressions aEmpty; + _out_rCondExp.swap( aEmpty ); + + _out_rCondExp[ eBetween ] = PConditionalExpression( new ConditionalExpression( "AND( ( $$ ) >= ( $1 ); ( $$ ) <= ( $2 ) )" ) ); + _out_rCondExp[ eNotBetween ] = PConditionalExpression( new ConditionalExpression( "NOT( AND( ( $$ ) >= ( $1 ); ( $$ ) <= ( $2 ) ) )" ) ); + _out_rCondExp[ eEqualTo ] = PConditionalExpression( new ConditionalExpression( "( $$ ) = ( $1 )" ) ); + _out_rCondExp[ eNotEqualTo ] = PConditionalExpression( new ConditionalExpression( "( $$ ) <> ( $1 )" ) ); + _out_rCondExp[ eGreaterThan ] = PConditionalExpression( new ConditionalExpression( "( $$ ) > ( $1 )" ) ); + _out_rCondExp[ eLessThan ] = PConditionalExpression( new ConditionalExpression( "( $$ ) < ( $1 )" ) ); + _out_rCondExp[ eGreaterOrEqual ] = PConditionalExpression( new ConditionalExpression( "( $$ ) >= ( $1 )" ) ); + _out_rCondExp[ eLessOrEqual ] = PConditionalExpression( new ConditionalExpression( "( $$ ) <= ( $1 )" ) ); + + return _out_rCondExp.size(); + } +//........................................................................ +} // namespace rptui +//........................................................................ diff --git a/reportdesign/source/core/misc/conditionupdater.cxx b/reportdesign/source/core/misc/conditionupdater.cxx new file mode 100644 index 000000000000..a3408e9d7d01 --- /dev/null +++ b/reportdesign/source/core/misc/conditionupdater.cxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "conditionupdater.hxx" +#include "reportformula.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/report/XFormatCondition.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace rptui +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::report::XReportControlModel; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::report::XFormatCondition; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::Exception; + /** === end UNO using === **/ + + //==================================================================== + //= ConditionUpdater + //==================================================================== + //-------------------------------------------------------------------- + ConditionUpdater::ConditionUpdater() + { + } + + //-------------------------------------------------------------------- + ConditionUpdater::~ConditionUpdater() + { + } + + //-------------------------------------------------------------------- + void ConditionUpdater::notifyPropertyChange( const PropertyChangeEvent& _rEvent ) + { + if ( !impl_lateInit_nothrow() ) + return; + + Reference< XReportControlModel > xRptControlModel( _rEvent.Source, UNO_QUERY ); + if ( xRptControlModel.is() && _rEvent.PropertyName.equalsAscii( "DataField" ) ) + { + ::rtl::OUString sOldDataSource, sNewDataSource; + OSL_VERIFY( _rEvent.OldValue >>= sOldDataSource ); + OSL_VERIFY( _rEvent.NewValue >>= sNewDataSource ); + impl_adjustFormatConditions_nothrow( xRptControlModel, sOldDataSource, sNewDataSource ); + } + } + + //-------------------------------------------------------------------- + bool ConditionUpdater::impl_lateInit_nothrow() + { + if ( !m_aConditionalExpressions.empty() ) + return true; + + ConditionalExpressionFactory::getKnownConditionalExpressions( m_aConditionalExpressions ); + return true; + } + + //-------------------------------------------------------------------- + void ConditionUpdater::impl_adjustFormatConditions_nothrow( const Reference< XReportControlModel >& _rxRptControlModel, + const ::rtl::OUString& _rOldDataSource, const ::rtl::OUString& _rNewDataSource ) + { + try + { + ReportFormula aOldContentFormula( _rOldDataSource ); + ::rtl::OUString sOldUnprefixed( aOldContentFormula.getBracketedFieldOrExpression() ); + ReportFormula aNewContentFormula( _rNewDataSource ); + ::rtl::OUString sNewUnprefixed( aNewContentFormula.getBracketedFieldOrExpression() ); + + sal_Int32 nCount( _rxRptControlModel->getCount() ); + Reference< XFormatCondition > xFormatCondition; + ::rtl::OUString sFormulaExpression, sLHS, sRHS; + for ( sal_Int32 i=0; i<nCount; ++i ) + { + xFormatCondition.set( _rxRptControlModel->getByIndex( i ), UNO_QUERY_THROW ); + ReportFormula aFormula( xFormatCondition->getFormula() ); + sFormulaExpression = aFormula.getExpression(); + + for ( ConditionalExpressions::const_iterator loop = m_aConditionalExpressions.begin(); + loop != m_aConditionalExpressions.end(); + ++loop + ) + { + if ( !loop->second->matchExpression( sFormulaExpression, sOldUnprefixed, sLHS, sRHS ) ) + continue; + + // the expression matches -> translate it to the new data source of the report control model + sFormulaExpression = loop->second->assembleExpression( sNewUnprefixed, sLHS, sRHS ); + aFormula = ReportFormula( ReportFormula::Expression, sFormulaExpression ); + xFormatCondition->setFormula( aFormula.getCompleteFormula() ); + break; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + +//........................................................................ +} // namespace rptui +//........................................................................ diff --git a/reportdesign/source/core/misc/makefile.mk b/reportdesign/source/core/misc/makefile.mk new file mode 100644 index 000000000000..749eb8214125 --- /dev/null +++ b/reportdesign/source/core/misc/makefile.mk @@ -0,0 +1,46 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=reportdesign +TARGET=core_misc +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/dll.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= $(SLO)$/conditionalexpression.obj \ + $(SLO)$/conditionupdater.obj \ + $(SLO)$/reportformula.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/reportdesign/source/core/misc/reportformula.cxx b/reportdesign/source/core/misc/reportformula.cxx new file mode 100644 index 000000000000..2ceef3340ef0 --- /dev/null +++ b/reportdesign/source/core/misc/reportformula.cxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "reportformula.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <rtl/ustrbuf.hxx> + +//........................................................................ +namespace rptui +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Any; + /** === end UNO using === **/ + + namespace + { + //---------------------------------------------------------------- + const ::rtl::OUString& lcl_getExpressionPrefix( sal_Int32* _pTakeLengthOrNull = NULL ) + { + static ::rtl::OUString s_sPrefix( RTL_CONSTASCII_USTRINGPARAM( "rpt:" ) ); + if ( _pTakeLengthOrNull ) + *_pTakeLengthOrNull = s_sPrefix.getLength(); + return s_sPrefix; + } + + //---------------------------------------------------------------- + const ::rtl::OUString& lcl_getFieldPrefix( sal_Int32* _pTakeLengthOrNull = NULL ) + { + static ::rtl::OUString s_sPrefix( RTL_CONSTASCII_USTRINGPARAM( "field:" ) ); + if ( _pTakeLengthOrNull ) + *_pTakeLengthOrNull = s_sPrefix.getLength(); + return s_sPrefix; + } + } + + //==================================================================== + //= ReportFormula + //==================================================================== + //-------------------------------------------------------------------- + ReportFormula::ReportFormula( const ::rtl::OUString& _rFormula ) + :m_eType( Invalid ) + { + impl_construct( _rFormula ); + } + + //-------------------------------------------------------------------- + ReportFormula::ReportFormula( const BindType _eType, const ::rtl::OUString& _rFieldOrExpression ) + :m_eType( _eType ) + { + switch ( m_eType ) + { + case Expression: + { + if ( _rFieldOrExpression.indexOf( lcl_getExpressionPrefix() ) == 0 ) + m_sCompleteFormula = _rFieldOrExpression; + else + m_sCompleteFormula = lcl_getExpressionPrefix() + _rFieldOrExpression; + } + break; + + case Field: + { + ::rtl::OUStringBuffer aBuffer; + aBuffer.append( lcl_getFieldPrefix() ); + aBuffer.appendAscii( "[" ); + aBuffer.append( _rFieldOrExpression ); + aBuffer.appendAscii( "]" ); + m_sCompleteFormula = aBuffer.makeStringAndClear(); + } + break; + default: + OSL_ENSURE( false, "ReportFormula::ReportFormula: illegal bind type!" ); + return; + } + + m_sUndecoratedContent = _rFieldOrExpression; + } + //-------------------------------------------------------------------- + ReportFormula::~ReportFormula() + { + } + //-------------------------------------------------------------------- + void ReportFormula::impl_construct( const ::rtl::OUString& _rFormula ) + { + m_sCompleteFormula = _rFormula; + + sal_Int32 nPrefixLen( -1 ); + // is it an ordinary expression? + if ( m_sCompleteFormula.indexOf( lcl_getExpressionPrefix( &nPrefixLen ) ) == 0 ) + { + m_eType = Expression; + m_sUndecoratedContent = m_sCompleteFormula.copy( nPrefixLen ); + return; + } + + /// does it refer to a field? + if ( m_sCompleteFormula.indexOf( lcl_getFieldPrefix( &nPrefixLen ) ) == 0 ) + { + if ( ( m_sCompleteFormula.getLength() >= nPrefixLen + 2 ) + && ( m_sCompleteFormula[ nPrefixLen ] == '[' ) + && ( m_sCompleteFormula[ m_sCompleteFormula.getLength() - 1 ] == ']' ) + ) + { + m_eType = Field; + m_sUndecoratedContent = m_sCompleteFormula.copy( nPrefixLen + 1, m_sCompleteFormula.getLength() - nPrefixLen - 2 ); + return; + } + } + + m_eType = Invalid; + } + + //-------------------------------------------------------------------- + ::rtl::OUString ReportFormula::getBracketedFieldOrExpression() const + { + bool bIsField = ( getType() == Field ); + ::rtl::OUStringBuffer aFieldContent; + if ( bIsField ) + aFieldContent.appendAscii( "[" ); + aFieldContent.append( getUndecoratedContent() ); + if ( bIsField ) + aFieldContent.appendAscii( "]" ); + + return aFieldContent.makeStringAndClear(); + } + //-------------------------------------------------------------------- + const ::rtl::OUString& ReportFormula::getUndecoratedContent() const + { + return m_sUndecoratedContent; + } + const ::rtl::OUString& ReportFormula::getCompleteFormula() const { return m_sCompleteFormula; } + bool ReportFormula::isValid() const { return getType() != Invalid; } + ReportFormula& ReportFormula::operator=(class ReportFormula const & _rHd) + { + if ( this == &_rHd ) + return *this; + m_eType = _rHd.m_eType; + m_sCompleteFormula = _rHd.m_sCompleteFormula; + m_sUndecoratedContent = _rHd.m_sUndecoratedContent; + return *this; + } + //-------------------------------------------------------------------- + ::rtl::OUString ReportFormula::getEqualUndecoratedContent() const + { + ::rtl::OUStringBuffer aBuffer; + aBuffer.appendAscii( "=" ); + aBuffer.append( getUndecoratedContent() ); + return aBuffer.makeStringAndClear(); + } + +//........................................................................ +} // namespace rptui +//........................................................................ + diff --git a/reportdesign/source/core/resource/core_resource.cxx b/reportdesign/source/core/resource/core_resource.cxx new file mode 100644 index 000000000000..eb0ad6b57d4f --- /dev/null +++ b/reportdesign/source/core/resource/core_resource.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "core_resource.hxx" +#include <tools/simplerm.hxx> + +// ---- needed as long as we have no contexts for components --- +#include <vcl/svapp.hxx> +//--------------------------------------------------- +#include <comphelper/configurationhelper.hxx> +#include <osl/thread.h> +#include <com/sun/star/util/XMacroExpander.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <rtl/uri.hxx> + +#ifndef _SOLAR_HRC +#include <svl/solar.hrc> +#endif +#include "ModuleHelper.hxx" +//......................................................................... +namespace reportdesign +{ + using namespace ::com::sun::star; + //================================================================== + //= ResourceManager + //================================================================== + SimpleResMgr* ResourceManager::m_pImpl = NULL; + + //------------------------------------------------------------------ + ResourceManager::EnsureDelete::~EnsureDelete() + { + delete ResourceManager::m_pImpl; + } + + //------------------------------------------------------------------ + void ResourceManager::ensureImplExists(const uno::Reference< lang::XMultiComponentFactory >& /* _rM */) + { + if (!m_pImpl) + { + // now that we have an impl class make sure it's deleted on unloading the library + static ResourceManager::EnsureDelete s_aDeleteTheImplClass; + + ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); + + rtl::OString sResLibName = rtl::OString( "rpt" ); + m_pImpl = SimpleResMgr::Create(sResLibName, aLocale); + } + } + + //------------------------------------------------------------------ + ::rtl::OUString ResourceManager::loadString(sal_uInt16 _nResId,const uno::Reference< lang::XMultiComponentFactory >& _rM) + { + ::rtl::OUString sReturn; + + ensureImplExists(_rM); + if (m_pImpl) + sReturn = m_pImpl->ReadString(_nResId); + + return sReturn; + } + +//......................................................................... +} +//......................................................................... + diff --git a/reportdesign/source/core/resource/makefile.mk b/reportdesign/source/core/resource/makefile.mk new file mode 100644 index 000000000000..d80adb525656 --- /dev/null +++ b/reportdesign/source/core/resource/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=reportdesign +TARGET=core_resource +ENABLE_EXCEPTIONS=TRUE +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/dll.pmk + +# --- Files -------------------------------------------------------- + +SRS1NAME=core_strings +SRC1FILES= \ + strings.src \ + +SLOFILES= $(SLO)$/core_resource.obj \ + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/reportdesign/source/core/resource/strings.src b/reportdesign/source/core/resource/strings.src new file mode 100644 index 000000000000..d6191e2f381e --- /dev/null +++ b/reportdesign/source/core/resource/strings.src @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "core_resource.hrc" + +String RID_STR_DETAIL +{ + Text [ en-US ] = "Detail"; +}; +String RID_STR_PAGE_HEADER +{ + Text [ en-US ] = "Page Header"; +}; +String RID_STR_PAGE_FOOTER +{ + Text [ en-US ] = "Page Footer"; +}; +String RID_STR_GROUP_HEADER +{ + Text [ en-US ] = "Group Header"; +}; +String RID_STR_GROUP_FOOTER +{ + Text [ en-US ] = "Group Footer"; +}; +String RID_STR_REPORT_HEADER +{ + Text [ en-US ] = "Report Header"; +}; +String RID_STR_REPORT_FOOTER +{ + Text [ en-US ] = "Report Footer"; +}; + +String RID_STR_PROPERTY_CHANGE_NOT_ALLOWED +{ + Text [ en-US ] = "The name '#1' already exists and can not be asssigned again."; +}; + +String RID_STR_ERROR_WRONG_ARGUMENT +{ + Text [ en-US ] = "You tried to set an illegal argument. Please have a look at '#1' for valid arguments."; +}; +String RID_STR_ARGUMENT_IS_NULL +{ + Text [ en-US ] = "The element is invalid."; +}; +String RID_STR_FIXEDTEXT +{ + Text [ en-US ] = "Label field" ; +}; +String RID_STR_FORMATTEDFIELD +{ + Text [ en-US ] = "Formatted field"; +}; +String RID_STR_IMAGECONTROL +{ + Text [ en-US ] = "Image control" ; +}; +String RID_STR_REPORT +{ + Text [ en-US ] = "Report"; +}; +String RID_STR_SHAPE +{ + Text [ en-US ] = "Shape"; +}; +String RID_STR_FIXEDLINE +{ + Text [ en-US ] = "Fixed line"; +}; diff --git a/reportdesign/source/core/sdr/ModuleHelper.cxx b/reportdesign/source/core/sdr/ModuleHelper.cxx new file mode 100644 index 000000000000..6337a28fcc46 --- /dev/null +++ b/reportdesign/source/core/sdr/ModuleHelper.cxx @@ -0,0 +1,141 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ModuleHelper.hxx" +#include <comphelper/configurationhelper.hxx> +#include <comphelper/processfactory.hxx> +#include <osl/thread.h> +#include <com/sun/star/util/XMacroExpander.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <rtl/uri.hxx> +#include <tools/debug.hxx> +#ifndef _SOLAR_HRC +#include <svl/solar.hrc> +#endif + +#define EXPAND_PROTOCOL "vnd.sun.star.expand:" +#define ENTER_MOD_METHOD() \ + ::osl::MutexGuard aGuard(s_aMutex); \ + ensureImpl() + +//......................................................................... +namespace rptui +{ +//......................................................................... + using namespace ::com::sun::star; +//========================================================================= +//= OModuleImpl +//========================================================================= +/** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner +*/ +class OModuleImpl +{ + ResMgr* m_pRessources; + +public: + /// ctor + OModuleImpl(); + ~OModuleImpl(); + + /// get the manager for the ressources of the module + ResMgr* getResManager(); +}; + +DBG_NAME( rpt_OModuleImpl ) +//------------------------------------------------------------------------- +OModuleImpl::OModuleImpl() + :m_pRessources(NULL) +{ + DBG_CTOR( rpt_OModuleImpl,NULL); + +} + +//------------------------------------------------------------------------- +OModuleImpl::~OModuleImpl() +{ + if (m_pRessources) + delete m_pRessources; + + DBG_DTOR( rpt_OModuleImpl,NULL); +} + +//------------------------------------------------------------------------- +ResMgr* OModuleImpl::getResManager() +{ + // note that this method is not threadsafe, which counts for the whole class ! + + if (!m_pRessources) + { + // create a manager with a fixed prefix + rtl::OString sName = rtl::OString( "rptui" ); + m_pRessources = ResMgr::CreateResMgr(sName); + } + return m_pRessources; +} + +//========================================================================= +//= OModule +//========================================================================= +::osl::Mutex OModule::s_aMutex; +sal_Int32 OModule::s_nClients = 0; +OModuleImpl* OModule::s_pImpl = NULL; +//------------------------------------------------------------------------- +ResMgr* OModule::getResManager() +{ + ENTER_MOD_METHOD(); + return s_pImpl->getResManager(); +} + +//------------------------------------------------------------------------- +void OModule::registerClient() +{ + ::osl::MutexGuard aGuard(s_aMutex); + ++s_nClients; +} + +//------------------------------------------------------------------------- +void OModule::revokeClient() +{ + ::osl::MutexGuard aGuard(s_aMutex); + if (!--s_nClients && s_pImpl) + { + delete s_pImpl; + s_pImpl = NULL; + } +} + +//------------------------------------------------------------------------- +void OModule::ensureImpl() +{ + if (s_pImpl) + return; + s_pImpl = new OModuleImpl(); +} + +//......................................................................... +} // namespace dbaui +//......................................................................... diff --git a/reportdesign/source/core/sdr/PropertyForward.cxx b/reportdesign/source/core/sdr/PropertyForward.cxx new file mode 100644 index 000000000000..dbd6d4da65a2 --- /dev/null +++ b/reportdesign/source/core/sdr/PropertyForward.cxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "PropertyForward.hxx" +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <comphelper/property.hxx> +#include <com/sun/star/sdbcx/XAppend.hpp> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include "corestrings.hrc" + +//........................................................................ +namespace rptui +{ +//........................................................................ + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + using namespace reportdesign; + +DBG_NAME( rpt_OPropertyMediator ) +OPropertyMediator::OPropertyMediator(const Reference< XPropertySet>& _xSource + ,const Reference< XPropertySet>& _xDest + ,const TPropertyNamePair& _aNameMap + ,sal_Bool _bReverse) + : OPropertyForward_Base(m_aMutex) + ,m_aNameMap(_aNameMap) + ,m_xSource(_xSource) + ,m_xDest(_xDest) + ,m_bInChange(sal_False) +{ + DBG_CTOR( rpt_OPropertyMediator,NULL); + osl_incrementInterlockedCount(&m_refCount); + OSL_ENSURE(m_xDest.is(),"Dest is NULL!"); + OSL_ENSURE(m_xSource.is(),"Source is NULL!"); + if ( m_xDest.is() && m_xSource.is() ) + { + try + { + m_xDestInfo = m_xDest->getPropertySetInfo(); + m_xSourceInfo = m_xSource->getPropertySetInfo(); + if ( _bReverse ) + { + ::comphelper::copyProperties(m_xDest,m_xSource); + TPropertyNamePair::iterator aIter = m_aNameMap.begin(); + TPropertyNamePair::iterator aEnd = m_aNameMap.end(); + for (; aIter != aEnd; ++aIter) + { + Property aProp = m_xSourceInfo->getPropertyByName(aIter->first); + if (0 == (aProp.Attributes & PropertyAttribute::READONLY)) + { + Any aValue = _xDest->getPropertyValue(aIter->second.first); + if ( 0 != (aProp.Attributes & PropertyAttribute::MAYBEVOID) || aValue.hasValue() ) + _xSource->setPropertyValue(aIter->first,aIter->second.second->operator()(aIter->second.first,aValue)); + } + } + } + else + { + ::comphelper::copyProperties(m_xSource,m_xDest); + TPropertyNamePair::iterator aIter = m_aNameMap.begin(); + TPropertyNamePair::iterator aEnd = m_aNameMap.end(); + for (; aIter != aEnd; ++aIter) + _xDest->setPropertyValue(aIter->second.first,aIter->second.second->operator()(aIter->second.first,_xSource->getPropertyValue(aIter->first))); + } + startListening(); + } + catch(Exception& e) + { + DBG_UNHANDLED_EXCEPTION(); + (void)e; + } + } // if ( m_xDest.is() && m_xSource.is() ) + osl_decrementInterlockedCount(&m_refCount); +} +// ----------------------------------------------------------------------------- +OPropertyMediator::~OPropertyMediator() +{ + DBG_DTOR( rpt_OPropertyMediator,NULL); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OPropertyMediator::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_bInChange ) + { + m_bInChange = sal_True; + try + { + sal_Bool bDest = (evt.Source == m_xDest); + Reference<XPropertySet> xProp = bDest ? m_xSource : m_xDest; + Reference<XPropertySetInfo> xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo; + if ( xProp.is() ) + { + if ( xPropInfo.is() ) + { + if ( xPropInfo->hasPropertyByName(evt.PropertyName) ) + xProp->setPropertyValue(evt.PropertyName,evt.NewValue); + else + { + TPropertyNamePair::iterator aFind = m_aNameMap.find(evt.PropertyName); + ::rtl::OUString sPropName; + if ( aFind != m_aNameMap.end() ) + sPropName = aFind->second.first; + else + { + aFind = ::std::find_if( + m_aNameMap.begin(), + m_aNameMap.end(), + ::std::compose1( + ::std::bind2nd(::std::equal_to< ::rtl::OUString >(), evt.PropertyName), + ::std::compose1(::std::select1st<TPropertyConverter>(),::std::select2nd<TPropertyNamePair::value_type>()) + ) + ); + if ( aFind != m_aNameMap.end() ) + sPropName = aFind->first; + } + if ( sPropName.getLength() && xPropInfo->hasPropertyByName(sPropName) ) + xProp->setPropertyValue(sPropName,aFind->second.second->operator()(sPropName,evt.NewValue)); + else if ( evt.PropertyName == PROPERTY_CHARFONTNAME + || evt.PropertyName == PROPERTY_CHARFONTSTYLENAME + || evt.PropertyName == PROPERTY_CHARSTRIKEOUT + || evt.PropertyName == PROPERTY_CHARWORDMODE + || evt.PropertyName == PROPERTY_CHARROTATION + || evt.PropertyName == PROPERTY_CHARSCALEWIDTH + || evt.PropertyName == PROPERTY_CHARFONTFAMILY + || evt.PropertyName == PROPERTY_CHARFONTCHARSET + || evt.PropertyName == PROPERTY_CHARFONTPITCH + || evt.PropertyName == PROPERTY_CHARHEIGHT + || evt.PropertyName == PROPERTY_CHARUNDERLINE + || evt.PropertyName == PROPERTY_CHARWEIGHT + || evt.PropertyName == PROPERTY_CHARPOSTURE) + { + xProp->setPropertyValue(PROPERTY_FONTDESCRIPTOR,m_xSource->getPropertyValue(PROPERTY_FONTDESCRIPTOR)); + } + } + } + } + } + catch(Exception&) + { + OSL_ENSURE(0,"Exception catched!"); + } + m_bInChange = sal_False; + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL OPropertyMediator::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + disposing(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OPropertyMediator::disposing() +{ + stopListening(); + m_xSource.clear(); + m_xSourceInfo.clear(); + m_xDest.clear(); + m_xDestInfo.clear(); +} +// ----------------------------------------------------------------------------- +void OPropertyMediator::stopListening() +{ + if ( m_xSource.is() ) + m_xSource->removePropertyChangeListener(::rtl::OUString(), this); + if ( m_xDest.is() ) + m_xDest->removePropertyChangeListener(::rtl::OUString(), this); +} +// ----------------------------------------------------------------------------- +void OPropertyMediator::startListening() +{ + if ( m_xSource.is() ) + m_xSource->addPropertyChangeListener(::rtl::OUString(), this); + if ( m_xDest.is() ) + m_xDest->addPropertyChangeListener(::rtl::OUString(), this); +} +// ----------------------------------------------------------------------------- +//........................................................................ +} // namespace dbaccess +//........................................................................ + diff --git a/reportdesign/source/core/sdr/ReportDrawPage.cxx b/reportdesign/source/core/sdr/ReportDrawPage.cxx new file mode 100644 index 000000000000..6ef0f970078f --- /dev/null +++ b/reportdesign/source/core/sdr/ReportDrawPage.cxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ReportDrawPage.hxx" +#include "RptObject.hxx" +#include "RptModel.hxx" +#include "RptDef.hxx" +#include "corestrings.hrc" +#include <comphelper/mimeconfighelper.hxx> +#include <comphelper/classids.hxx> +#include <comphelper/embeddedobjectcontainer.hxx> +#include <comphelper/documentconstants.hxx> + +#include <svx/svdmodel.hxx> +#include <com/sun/star/report/XFixedLine.hpp> +#include <com/sun/star/beans/NamedValue.hpp> + +#include <tools/diagnose_ex.h> +#include <svx/unoshape.hxx> + +namespace reportdesign +{ + using namespace ::com::sun::star; + using namespace rptui; + +OReportDrawPage::OReportDrawPage(SdrPage* _pPage + ,const uno::Reference< report::XSection >& _xSection) +: SvxDrawPage(_pPage) +,m_xSection(_xSection) +{ +} + +SdrObject* OReportDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xDescr ) throw () +{ + uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY); + if ( xReportComponent.is() ) + return OObjectBase::createObject(xReportComponent); + return SvxDrawPage::_CreateSdrObject( xDescr ); +} + +uno::Reference< drawing::XShape > OReportDrawPage::_CreateShape( SdrObject *pObj ) const throw () +{ + OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj); + if ( !pBaseObj ) + return SvxDrawPage::_CreateShape( pObj ); + + uno::Reference< report::XSection> xSection = m_xSection; + uno::Reference< lang::XMultiServiceFactory> xFactory; + if ( xSection.is() ) + xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY); + uno::Reference< drawing::XShape > xRet; + uno::Reference< drawing::XShape > xShape; + if ( xFactory.is() ) + { + bool bChangeOrientation = false; + ::rtl::OUString sServiceName = pBaseObj->getServiceName(); + OSL_ENSURE(sServiceName.getLength(),"No Service Name given!"); + + if ( pObj->ISA(OUnoObject) ) + { + OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObj); + if ( pUnoObj->GetObjIdentifier() == OBJ_DLG_FIXEDTEXT ) + { + uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() ) + xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True)); + } + else + bChangeOrientation = pUnoObj->GetObjIdentifier() == OBJ_DLG_HFIXEDLINE; + SvxShapeControl* pShape = new SvxShapeControl( pObj ); + xShape.set(*pShape,uno::UNO_QUERY); + pShape->setShapeKind(pObj->GetObjIdentifier()); + } + else if ( pObj->ISA(OCustomShape) ) + { + SvxCustomShape* pShape = new SvxCustomShape( pObj ); + uno::Reference < drawing::XEnhancedCustomShapeDefaulter > xShape2 = pShape; + xShape.set(xShape2,uno::UNO_QUERY); + pShape->setShapeKind(pObj->GetObjIdentifier()); + } + else if ( pObj->ISA(SdrOle2Obj) ) + { + SdrOle2Obj* pOle2Obj = dynamic_cast<SdrOle2Obj*>(pObj); + if ( !pOle2Obj->GetObjRef().is() ) + { + sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; + uno::Reference < embed::XEmbeddedObject > xObj; + ::rtl::OUString sName; + xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject( + ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("80243D39-6741-46C5-926E-069164FF87BB"))), sName ); + OSL_ENSURE(xObj.is(),"Embedded Object could not be created!"); + + /************************************************** + * Das leere OLE-Objekt bekommt ein neues IPObj + **************************************************/ + pObj->SetEmptyPresObj(FALSE); + pOle2Obj->SetOutlinerParaObject(NULL); + pOle2Obj->SetObjRef(xObj); + pOle2Obj->SetPersistName(sName); + pOle2Obj->SetName(sName); + pOle2Obj->SetAspect(nAspect); + Rectangle aRect = pOle2Obj->GetLogicRect(); + + Size aTmp = aRect.GetSize(); + awt::Size aSz( aTmp.Width(), aTmp.Height() ); + xObj->setVisualAreaSize( nAspect, aSz ); + } + SvxOle2Shape* pShape = new SvxOle2Shape( pObj ); + xShape.set(*pShape,uno::UNO_QUERY); + pShape->setShapeKind(pObj->GetObjIdentifier()); + //xShape = new SvxOle2Shape( pOle2Obj ); + } + + if ( !xShape.is() ) + xShape.set( SvxDrawPage::_CreateShape( pObj ) ); + + try + { + OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel()); + xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + return xRet; +} + +} diff --git a/reportdesign/source/core/sdr/ReportUndoFactory.cxx b/reportdesign/source/core/sdr/ReportUndoFactory.cxx new file mode 100644 index 000000000000..e0e089e651b2 --- /dev/null +++ b/reportdesign/source/core/sdr/ReportUndoFactory.cxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ReportUndoFactory.hxx" +#include "RptObject.hxx" +#include "UndoActions.hxx" +#include "RptResId.hrc" + +namespace rptui +{ + using namespace ::com::sun::star; +// ----------------------------------------------------------------------------- +SdrUndoAction* lcl_createUndo(SdrObject& rObject,Action _eAction,USHORT _nCommentId) +{ + OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject); + if ( !pObj ) + return NULL; + uno::Reference< report::XReportComponent> xReportComponent = pObj->getReportComponent(); + uno::Reference< report::XSection> xSection = pObj->getSection(); + uno::Reference< report::XGroup> xGroup = xSection->getGroup(); + SdrUndoAction* pUndo = NULL; + if ( xGroup.is() ) + pUndo = new OUndoGroupSectionAction(*rObject.GetModel(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,_nCommentId); + else + pUndo = new OUndoReportSectionAction(*rObject.GetModel(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,_nCommentId); + return pUndo; +} +// ----------------------------------------------------------------------------- +DBG_NAME( rpt_OReportUndoFactory ) +// ----------------------------------------------------------------------------- +OReportUndoFactory::OReportUndoFactory() : m_pUndoFactory(new SdrUndoFactory) +{ + DBG_CTOR( rpt_OReportUndoFactory,NULL); +} +// ----------------------------------------------------------------------------- +OReportUndoFactory::~OReportUndoFactory() +{ + DBG_DTOR( rpt_OReportUndoFactory,NULL); +} +/////////////////////////////////////////////////////////////////////// +// shapes +SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject ) +{ + return m_pUndoFactory->CreateUndoMoveObject( rObject ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist ) +{ + return m_pUndoFactory->CreateUndoMoveObject( rObject, rDist ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoGeoObject( SdrObject& rObject ) +{ + return m_pUndoFactory->CreateUndoGeoObject( rObject ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText ) +{ + return m_pUndoFactory->CreateUndoAttrObject( rObject, bStyleSheet1 ? TRUE : FALSE, bSaveText ? TRUE : FALSE ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect ) +{ + return m_pUndoFactory->CreateUndoRemoveObject( rObject, bOrdNumDirect ? TRUE : FALSE ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool /*bOrdNumDirect*/ ) +{ + return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool /*bOrdNumDirect*/ ) +{ + return lcl_createUndo(rObject,rptui::Removed,RID_STR_UNDO_DELETE_CONTROL); + //return m_pUndoFactory->CreateUndoDeleteObject( rObject, bOrdNumDirect ? TRUE : FALSE ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool /*bOrdNumDirect*/ ) +{ + return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect ) +{ + return m_pUndoFactory->CreateUndoCopyObject( rObject, bOrdNumDirect ? TRUE : FALSE ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1) +{ + return m_pUndoFactory->CreateUndoObjectOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect ) +{ + return m_pUndoFactory->CreateUndoReplaceObject( rOldObject, rNewObject, bOrdNumDirect ? TRUE : FALSE ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer ) +{ + return m_pUndoFactory->CreateUndoObjectLayerChange( rObject, aOldLayer, aNewLayer ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) +{ + return m_pUndoFactory->CreateUndoObjectSetText( rNewObj, nText ); +} + +// layer +SdrUndoAction* OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) +{ + return m_pUndoFactory->CreateUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) +{ + return m_pUndoFactory->CreateUndoDeleteLayer( nLayerNum, rNewLayerAdmin, rNewModel ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1) +{ + return m_pUndoFactory->CreateUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 ); +} + +// page +SdrUndoAction* OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage) +{ + return m_pUndoFactory->CreateUndoDeletePage( rPage ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage) +{ + return m_pUndoFactory->CreateUndoNewPage( rPage ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoCopyPage(SdrPage& rPage) +{ + return m_pUndoFactory->CreateUndoCopyPage( rPage ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) +{ + return m_pUndoFactory->CreateUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 ); +} + // master page +SdrUndoAction* OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage) +{ + return m_pUndoFactory->CreateUndoPageRemoveMasterPage( rChangedPage ); +} + +SdrUndoAction* OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage) +{ + return m_pUndoFactory->CreateUndoPageChangeMasterPage(rChangedPage); +} + +//================================================================== +} //rptui +//================================================================== + diff --git a/reportdesign/source/core/sdr/RptModel.cxx b/reportdesign/source/core/sdr/RptModel.cxx new file mode 100644 index 000000000000..7327456c7940 --- /dev/null +++ b/reportdesign/source/core/sdr/RptModel.cxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "RptModel.hxx" +#include "RptPage.hxx" +#include <dbaccess/singledoccontroller.hxx> +#include <tools/debug.hxx> +#include <unotools/pathoptions.hxx> + +#include "UndoActions.hxx" +#include "UndoEnv.hxx" +#include "ReportUndoFactory.hxx" +#include "ReportDefinition.hxx" +#define ITEMID_COLOR 1 +#define ITEMID_BRUSH 2 +#define ITEMID_FONT 3 +#define ITEMID_FONTHEIGHT 4 + +#include <svx/tbcontrl.hxx> +#include "rptui_slotid.hrc" +#include "RptDef.hxx" +#include "corestrings.hrc" +#include "FixedLine.hxx" +#include "FormattedField.hxx" +#include "FixedText.hxx" +#include "ImageControl.hxx" +#include "Shape.hxx" + +namespace rptui +{ +using namespace reportdesign; +using namespace com::sun::star; +DBG_NAME( rpt_OReportModel ) +TYPEINIT1(OReportModel,SdrModel); + +//---------------------------------------------------------------------------- + +OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition) : + SdrModel(SvtPathOptions().GetPalettePath(),NULL,_pReportDefinition) + ,m_pController(NULL) + ,m_pReportDefinition(_pReportDefinition) +{ + DBG_CTOR( rpt_OReportModel,0); + SetAllowShapePropertyChangeListener(true); + m_pUndoEnv = new OXUndoEnvironment(*this); + m_pUndoEnv->acquire(); + SetSdrUndoFactory(new OReportUndoFactory); + + // SvxFontNameToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONT); + //SvxFontHeightToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT); + //SvxFontColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR); + //SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2); + //SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND); + //SvxColorToolBoxControl::RegisterControl(SID_BACKGROUND_COLOR); +} + +//---------------------------------------------------------------------------- +OReportModel::~OReportModel() +{ + DBG_DTOR( rpt_OReportModel,0); + detachController(); + m_pUndoEnv->release(); +} +// ----------------------------------------------------------------------------- +void OReportModel::detachController() +{ + m_pReportDefinition = NULL; + m_pController = NULL; + m_pUndoEnv->EndListening( *this ); + ClearUndoBuffer(); + m_pUndoEnv->Clear(OXUndoEnvironment::Accessor()); +} +//---------------------------------------------------------------------------- +SdrPage* OReportModel::AllocPage(FASTBOOL /*bMasterPage*/) +{ + DBG_CHKTHIS( rpt_OReportModel, 0); + OSL_ENSURE(0,"Who called me!"); + return NULL; +} + +//---------------------------------------------------------------------------- + +void OReportModel::SetChanged( sal_Bool bChanged ) +{ + SdrModel::SetChanged( bChanged ); + SetModified( bChanged ); +} + +//---------------------------------------------------------------------------- + +Window* OReportModel::GetCurDocViewWin() +{ + return 0; +} + +//---------------------------------------------------------------------------- +OXUndoEnvironment& OReportModel::GetUndoEnv() +{ + return *m_pUndoEnv; +} +//---------------------------------------------------------------------------- +void OReportModel::SetModified(sal_Bool _bModified) +{ + if ( m_pController ) + m_pController->setModified(_bModified); +} +// ----------------------------------------------------------------------------- +SdrPage* OReportModel::RemovePage(USHORT nPgNum) +{ + OReportPage* pPage = dynamic_cast<OReportPage*>(SdrModel::RemovePage(nPgNum)); + //if ( pPage ) + //{ + // m_pUndoEnv->RemoveSection(pPage); + //} + return pPage; +} +// ----------------------------------------------------------------------------- +OReportPage* OReportModel::createNewPage(const uno::Reference< report::XSection >& _xSection) +{ + OReportPage* pPage = new OReportPage( *this ,_xSection); + InsertPage(pPage); + m_pUndoEnv->AddSection(_xSection); + return pPage; +} +// ----------------------------------------------------------------------------- +OReportPage* OReportModel::getPage(const uno::Reference< report::XSection >& _xSection) +{ + OReportPage* pPage = NULL; + USHORT nCount = GetPageCount(); + for (USHORT i = 0; i < nCount && !pPage ; ++i) + { + OReportPage* pRptPage = PTR_CAST( OReportPage, GetPage(i) ); + if ( pRptPage && pRptPage->getSection() == _xSection ) + pPage = pRptPage; + } + return pPage; +} +// ----------------------------------------------------------------------------- +SvxNumType OReportModel::GetPageNumType() const +{ + uno::Reference< report::XReportDefinition > xReportDefinition( getReportDefinition() ); + if ( xReportDefinition.is() ) + return (SvxNumType)getStyleProperty<sal_Int16>(xReportDefinition,reportdesign::PROPERTY_NUMBERINGTYPE); + return SVX_ARABIC; +} + +// ----------------------------------------------------------------------------- +uno::Reference< report::XReportDefinition > OReportModel::getReportDefinition() const +{ + uno::Reference< report::XReportDefinition > xReportDefinition = m_pReportDefinition; + OSL_ENSURE( xReportDefinition.is(), "OReportModel::getReportDefinition: invalid model at our controller!" ); + return xReportDefinition; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OReportModel::createUnoModel() +{ + return uno::Reference< uno::XInterface >(getReportDefinition(),uno::UNO_QUERY); +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OReportModel::createShape(const ::rtl::OUString& aServiceSpecifier,uno::Reference< drawing::XShape >& _rShape,sal_Int32 nOrientation) +{ + uno::Reference< uno::XInterface > xRet; + if ( _rShape.is() ) + { + if ( aServiceSpecifier == SERVICE_FORMATTEDFIELD ) + { + uno::Reference<report::XFormattedField> xProp = new OFormattedField(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape); + xRet = xProp; + if ( _rShape.is() ) + throw uno::Exception(); + xProp->setPropertyValue( PROPERTY_FORMATSSUPPLIER, uno::makeAny(uno::Reference< util::XNumberFormatsSupplier >(*m_pReportDefinition,uno::UNO_QUERY)) ); + } + else if ( aServiceSpecifier == SERVICE_FIXEDTEXT) + { + xRet = static_cast<cppu::OWeakObject*>(new OFixedText(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape)); + if ( _rShape.is() ) + throw uno::Exception(); + } + else if ( aServiceSpecifier == SERVICE_FIXEDLINE) + { + xRet = static_cast<cppu::OWeakObject*>(new OFixedLine(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape,nOrientation)); + if ( _rShape.is() ) + throw uno::Exception(); + } + else if ( aServiceSpecifier == SERVICE_IMAGECONTROL ) + { + xRet = static_cast<cppu::OWeakObject*>(new OImageControl(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape)); + if ( _rShape.is() ) + throw uno::Exception(); + } + else if ( aServiceSpecifier == SERVICE_REPORTDEFINITION ) + { + xRet = static_cast<cppu::OWeakObject*>(new OReportDefinition(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape)); + if ( _rShape.is() ) + throw uno::Exception(); + } + else if ( _rShape.is() ) + { + xRet = static_cast<cppu::OWeakObject*>(new OShape(m_pReportDefinition->getContext(),m_pReportDefinition,_rShape,aServiceSpecifier)); + if ( _rShape.is() ) + throw uno::Exception(); + } + } + return xRet; +} +//================================================================== +} //rptui +//================================================================== diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx new file mode 100644 index 000000000000..7d1cdbc6db30 --- /dev/null +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -0,0 +1,1256 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "RptObject.hxx" +#include <vector> +#include <algorithm> + +#include <RptDef.hxx> +#include <svx/unoshape.hxx> +#include "RptModel.hxx" +#include "RptObjectListener.hxx" +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/convert.hxx> +#include "RptPage.hxx" +#include "corestrings.hrc" +#include <dbaccess/singledoccontroller.hxx> +#include "ModuleHelper.hxx" + +#include <RptResId.hrc> +#include <svx/xflclit.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xlineit0.hxx> +#include <svx/sderitm.hxx> +#include <svx/xlnwtit.hxx> +#include <svx/xlntrit.hxx> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/awt/XTabControllerModel.hpp> +#include <com/sun/star/awt/XUnoControlContainer.hpp> +#include <com/sun/star/awt/XVclContainerPeer.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/TextAlign.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/script/XScriptEventsSupplier.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/report/XShape.hpp> +#include <com/sun/star/report/XFixedLine.hpp> +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/report/XFormattedField.hpp> +#include <comphelper/genericpropertyset.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/property.hxx> +#include <tools/diagnose_ex.h> +#include "PropertyForward.hxx" +#include <connectivity/dbtools.hxx> +#include <connectivity/dbconversion.hxx> +#include "UndoActions.hxx" +#include "UndoEnv.hxx" +#include <algorithm> +#include <functional> + +namespace rptui +{ + +using namespace ::com::sun::star; +using namespace uno; +using namespace beans; +using namespace reportdesign; +using namespace container; +using namespace script; +using namespace report; +//---------------------------------------------------------------------------- +sal_uInt16 OObjectBase::getObjectType(const uno::Reference< report::XReportComponent>& _xComponent) +{ + uno::Reference< lang::XServiceInfo > xServiceInfo( _xComponent , uno::UNO_QUERY ); + OSL_ENSURE(xServiceInfo.is(),"Who deletes the XServiceInfo interface!"); + if ( xServiceInfo.is() ) + { + if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT )) + return OBJ_DLG_FIXEDTEXT; + if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE )) + { + uno::Reference< report::XFixedLine> xFixedLine(_xComponent,uno::UNO_QUERY); + return xFixedLine->getOrientation() ? OBJ_DLG_HFIXEDLINE : OBJ_DLG_VFIXEDLINE; + } + if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL)) + return OBJ_DLG_IMAGECONTROL; + if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD )) + return OBJ_DLG_FORMATTEDFIELD; + if ( xServiceInfo->supportsService( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")) ) ) + return OBJ_OLE2; + if ( xServiceInfo->supportsService( SERVICE_SHAPE )) + return OBJ_CUSTOMSHAPE; + if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) ) + return OBJ_DLG_SUBREPORT; + return OBJ_OLE2; + } + return 0; +} +// ----------------------------------------------------------------------------- +SdrObject* OObjectBase::createObject(const uno::Reference< report::XReportComponent>& _xComponent) +{ + SdrObject* pNewObj = NULL; + sal_uInt16 nType = OObjectBase::getObjectType(_xComponent); + switch( nType ) + { + case OBJ_DLG_FIXEDTEXT: + { + OUnoObject* pUnoObj = new OUnoObject( _xComponent + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")) + ,OBJ_DLG_FIXEDTEXT); + pNewObj = pUnoObj; + + uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() ) + xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True)); + } + break; + case OBJ_DLG_IMAGECONTROL: + pNewObj = new OUnoObject(_xComponent + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl")) + ,OBJ_DLG_IMAGECONTROL); + break; + case OBJ_DLG_FORMATTEDFIELD: + pNewObj = new OUnoObject( _xComponent + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField")) + ,OBJ_DLG_FORMATTEDFIELD); + break; + case OBJ_DLG_HFIXEDLINE: + case OBJ_DLG_VFIXEDLINE: + pNewObj = new OUnoObject( _xComponent + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel")) + ,nType); + break; + case OBJ_CUSTOMSHAPE: + pNewObj = OCustomShape::Create( _xComponent ); + try + { + sal_Bool bOpaque = sal_False; + _xComponent->getPropertyValue(PROPERTY_OPAQUE) >>= bOpaque; + pNewObj->SetLayer(bOpaque ? RPT_LAYER_FRONT : RPT_LAYER_BACK); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + break; + case OBJ_DLG_SUBREPORT: + case OBJ_OLE2: + pNewObj = OOle2Obj::Create( _xComponent,nType ); + break; + default: + OSL_ENSURE(0,"Unknown object id"); + break; + } + + ensureSdrObjectOwnership( _xComponent ); + + return pNewObj; +} +// ----------------------------------------------------------------------------- +namespace +{ + class ParaAdjust : public AnyConverter + { + public: + virtual ::com::sun::star::uno::Any operator() (const ::rtl::OUString& _sPropertyName,const ::com::sun::star::uno::Any& lhs) const + { + uno::Any aRet; + if ( _sPropertyName.equalsAscii(PROPERTY_PARAADJUST) ) + { + sal_Int16 nTextAlign = 0; + lhs >>= nTextAlign; + switch(nTextAlign) + { + case awt::TextAlign::LEFT: + nTextAlign = style::ParagraphAdjust_LEFT; + break; + case awt::TextAlign::CENTER: + nTextAlign = style::ParagraphAdjust_CENTER; + break; + case awt::TextAlign::RIGHT: + nTextAlign = style::ParagraphAdjust_RIGHT; + break; + default: + OSL_ENSURE(0,"Illegal text alignment value!"); + break; + } // switch(nTextAlign) + aRet <<= (style::ParagraphAdjust)nTextAlign; + } + else + { + sal_Int16 nTextAlign = 0; + sal_Int16 eParagraphAdjust = 0; + lhs >>= eParagraphAdjust; + switch(eParagraphAdjust) + { + case style::ParagraphAdjust_LEFT: + case style::ParagraphAdjust_BLOCK: + nTextAlign = awt::TextAlign::LEFT; + break; + case style::ParagraphAdjust_CENTER: + nTextAlign = awt::TextAlign::CENTER; + break; + case style::ParagraphAdjust_RIGHT: + nTextAlign = awt::TextAlign::RIGHT; + break; + default: + OSL_ENSURE(0,"Illegal text alignment value!"); + break; + } // switch(eParagraphAdjust) + aRet <<= nTextAlign; + } + return aRet; + } + }; +} +// ----------------------------------------------------------------------------- +const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId) +{ + switch(_nObjectId) + { + case OBJ_DLG_IMAGECONTROL: + { + static TPropertyNamePair s_aNameMap; + if ( s_aNameMap.empty() ) + { + ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter()); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter))); + //s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,PROPERTY_ALIGN)); + } + return s_aNameMap; + } + + case OBJ_DLG_FIXEDTEXT: + { + static TPropertyNamePair s_aNameMap; + if ( s_aNameMap.empty() ) + { + ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter()); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR,TPropertyConverter(PROPERTY_TEXTCOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR,TPropertyConverter(PROPERTY_TEXTLINECOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF,TPropertyConverter(PROPERTY_FONTRELIEF,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT,TPropertyConverter(PROPERTY_FONTHEIGHT,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT,TPropertyConverter(PROPERTY_FONTSTRIKEOUT,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK,TPropertyConverter(PROPERTY_FONTEMPHASISMARK,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter))); + + ::boost::shared_ptr<AnyConverter> aParaAdjust(new ParaAdjust()); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aParaAdjust))); + } + return s_aNameMap; + } + case OBJ_DLG_FORMATTEDFIELD: + { + static TPropertyNamePair s_aNameMap; + if ( s_aNameMap.empty() ) + { + ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter()); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR,TPropertyConverter(PROPERTY_TEXTCOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR,TPropertyConverter(PROPERTY_TEXTLINECOLOR,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF,TPropertyConverter(PROPERTY_FONTRELIEF,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT,TPropertyConverter(PROPERTY_FONTHEIGHT,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT,TPropertyConverter(PROPERTY_FONTSTRIKEOUT,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK,TPropertyConverter(PROPERTY_FONTEMPHASISMARK,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter))); + //s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aNoConverter))); + ::boost::shared_ptr<AnyConverter> aParaAdjust(new ParaAdjust()); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aParaAdjust))); + } + return s_aNameMap; + } + + case OBJ_CUSTOMSHAPE: + { + static TPropertyNamePair s_aNameMap; + if ( s_aNameMap.empty() ) + { + ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter()); + s_aNameMap.insert(TPropertyNamePair::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillColor")),TPropertyConverter(PROPERTY_CONTROLBACKGROUND,aNoConverter))); + s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aNoConverter))); + } + return s_aNameMap; + } + + default: + break; + } + static TPropertyNamePair s_aEmptyNameMap; + return s_aEmptyNameMap; +} +// ----------------------------------------------------------------------------- + +DBG_NAME( rpt_OObjectBase ) +OObjectBase::OObjectBase(const uno::Reference< report::XReportComponent>& _xComponent) +:m_bIsListening(sal_False) +{ + DBG_CTOR( rpt_OObjectBase,NULL); + m_xReportComponent = _xComponent; +} +//---------------------------------------------------------------------------- +OObjectBase::OObjectBase(const ::rtl::OUString& _sComponentName) +:m_sComponentName(_sComponentName) +,m_bIsListening(sal_False) +{ + DBG_CTOR( rpt_OObjectBase,NULL); +} +//---------------------------------------------------------------------------- +OObjectBase::~OObjectBase() +{ + DBG_DTOR( rpt_OObjectBase,NULL); + m_xMediator.reset(); + if ( isListening() ) + EndListening(); + m_xReportComponent.clear(); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection> OObjectBase::getSection() const +{ + uno::Reference< report::XSection> xSection; + OReportPage* pPage = dynamic_cast<OReportPage*>(GetImplPage()); + if ( pPage ) + xSection = pPage->getSection(); + return xSection; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XReportComponent> OObjectBase::getReportComponent() const +{ + return m_xReportComponent; +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySet> OObjectBase::getAwtComponent() +{ + return uno::Reference< beans::XPropertySet>(); +} +//---------------------------------------------------------------------------- +void OObjectBase::StartListening() +{ + DBG_CHKTHIS( rpt_OObjectBase,NULL); + OSL_ENSURE(!isListening(), "OUnoObject::StartListening: already listening!"); + + if ( !isListening() && m_xReportComponent.is() ) + { + m_bIsListening = sal_True; + + if ( !m_xPropertyChangeListener.is() ) + { + m_xPropertyChangeListener = new OObjectListener( this ); + // register listener to all properties + m_xReportComponent->addPropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener ); + } + } +} +//---------------------------------------------------------------------------- +void OObjectBase::EndListening(sal_Bool /*bRemoveListener*/) +{ + DBG_CHKTHIS( rpt_OObjectBase,NULL); + OSL_ENSURE(!m_xReportComponent.is() || isListening(), "OUnoObject::EndListening: not listening currently!"); + + m_bIsListening = sal_False; + if ( isListening() && m_xReportComponent.is() ) + { + // XPropertyChangeListener + if ( m_xPropertyChangeListener.is() ) + { + // remove listener + try + { + m_xReportComponent->removePropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener ); + } + catch(uno::Exception) + { + OSL_ENSURE(0,"OObjectBase::EndListening: Exception caught!"); + } + } + m_xPropertyChangeListener.clear(); + } +} +//---------------------------------------------------------------------------- +void OObjectBase::SetPropsFromRect(const Rectangle& _rRect) +{ + DBG_CHKTHIS( rpt_OObjectBase,NULL); + // set properties + OReportPage* pPage = dynamic_cast<OReportPage*>(GetImplPage()); + if ( pPage && !_rRect.IsEmpty() ) + { + uno::Reference<report::XSection> xSection = pPage->getSection(); + if ( xSection.is() && (static_cast<sal_uInt32>(_rRect.getHeight() + _rRect.Top()) > xSection->getHeight()) ) + xSection->setHeight(_rRect.getHeight() + _rRect.Top()); + + // TODO + //pModel->GetRefDevice()->Invalidate(INVALIDATE_CHILDREN); + } +} +//---------------------------------------------------------------------------- +void OObjectBase::_propertyChange( const beans::PropertyChangeEvent& /*evt*/ ) throw( uno::RuntimeException) +{ + DBG_CHKTHIS( rpt_OObjectBase,NULL); +} +//---------------------------------------------------------------------------- +void OObjectBase::SetObjectItemHelper(const SfxPoolItem& /*rItem*/) +{ + // do nothing +} + +//---------------------------------------------------------------------------- +sal_Bool OObjectBase::supportsService( const ::rtl::OUString& _sServiceName ) const +{ + DBG_CHKTHIS( rpt_OObjectBase,NULL); + sal_Bool bSupports = sal_False; + + Reference< lang::XServiceInfo > xServiceInfo( m_xReportComponent , UNO_QUERY ); + // TODO: cache xServiceInfo as member? + if ( xServiceInfo.is() ) + bSupports = xServiceInfo->supportsService( _sServiceName ); + + return bSupports; +} + +//---------------------------------------------------------------------------- +void OObjectBase::ensureSdrObjectOwnership( const uno::Reference< uno::XInterface >& _rxShape ) +{ + // UNDO in the report designer is implemented at the level of the XShapes, not + // at the level of SdrObjects. That is, if an object is removed from the report + // design, then this happens by removing the XShape from the UNO DrawPage, and + // putting this XShape (resp. the ReportComponent which wraps it) into an UNDO + // action. + // Unfortunately, the SvxDrawPage implementation usually deletes SdrObjects + // which are removed from it, which is deadly for us. To prevent this, + // we give the XShape implementation the ownership of the SdrObject, which + // ensures the SvxDrawPage won't delete it. + SvxShape* pShape = SvxShape::getImplementation( _rxShape ); + OSL_ENSURE( pShape, "OObjectBase::ensureSdrObjectOwnership: can't access the SvxShape!" ); + if ( pShape ) + { + OSL_ENSURE( !pShape->HasSdrObjectOwnership(), "OObjectBase::ensureSdrObjectOwnership: called twice?" ); + pShape->TakeSdrObjectOwnership(); + } +} + +//---------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OObjectBase::getUnoShapeOf( SdrObject& _rSdrObject ) +{ + uno::Reference< uno::XInterface > xShape( _rSdrObject.getWeakUnoShape() ); + if ( xShape.is() ) + return xShape; + + xShape = _rSdrObject.SdrObject::getUnoShape(); + if ( !xShape.is() ) + return xShape; + + ensureSdrObjectOwnership( xShape ); + + m_xKeepShapeAlive = xShape; + return xShape; +} + +//---------------------------------------------------------------------------- +TYPEINIT1(OCustomShape, SdrObjCustomShape); +DBG_NAME( rpt_OCustomShape ); +OCustomShape::OCustomShape(const uno::Reference< report::XReportComponent>& _xComponent + ) + :SdrObjCustomShape() + ,OObjectBase(_xComponent) +{ + DBG_CTOR( rpt_OCustomShape, NULL); + impl_setUnoShape( uno::Reference< uno::XInterface >(_xComponent,uno::UNO_QUERY) ); + m_bIsListening = sal_True; +} +//---------------------------------------------------------------------------- +OCustomShape::OCustomShape(const ::rtl::OUString& _sComponentName) + :SdrObjCustomShape() + ,OObjectBase(_sComponentName) +{ + DBG_CTOR( rpt_OCustomShape, NULL); + m_bIsListening = sal_True; +} + +//---------------------------------------------------------------------------- +OCustomShape::~OCustomShape() +{ + DBG_DTOR( rpt_OCustomShape, NULL); +} +// ----------------------------------------------------------------------------- +UINT16 OCustomShape::GetObjIdentifier() const +{ + return UINT16(OBJ_CUSTOMSHAPE); +} +//---------------------------------------------------------------------------- +UINT32 OCustomShape::GetObjInventor() const +{ + return ReportInventor; +} +//---------------------------------------------------------------------------- +SdrPage* OCustomShape::GetImplPage() const +{ + return GetPage(); +} +//---------------------------------------------------------------------------- +void OCustomShape::SetSnapRectImpl(const Rectangle& _rRect) +{ + SetSnapRect( _rRect ); +} +//---------------------------------------------------------------------------- +sal_Int32 OCustomShape::GetStep() const +{ + // get step property + sal_Int32 nStep = 0; + OSL_ENSURE(0,"Who called me!"); + return nStep; +} +//---------------------------------------------------------------------------- +void OCustomShape::NbcMove( const Size& rSize ) +{ + if ( m_bIsListening ) + { + m_bIsListening = sal_False; + + if ( m_xReportComponent.is() ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + m_xReportComponent->setPositionX(m_xReportComponent->getPositionX() + rSize.A()); + m_xReportComponent->setPositionY(m_xReportComponent->getPositionY() + rSize.B()); + } + + // set geometry properties + SetPropsFromRect(GetSnapRect()); + + m_bIsListening = sal_True; + } + else + SdrObjCustomShape::NbcMove( rSize ); +} +//---------------------------------------------------------------------------- +void OCustomShape::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract) +{ + SdrObjCustomShape::NbcResize( rRef, xFract, yFract ); + + SetPropsFromRect(GetSnapRect()); +} +//---------------------------------------------------------------------------- +void OCustomShape::NbcSetLogicRect(const Rectangle& rRect) +{ + SdrObjCustomShape::NbcSetLogicRect(rRect); + SetPropsFromRect(rRect); +} +//---------------------------------------------------------------------------- +FASTBOOL OCustomShape::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) +{ + FASTBOOL bResult = SdrObjCustomShape::EndCreate(rStat, eCmd); + if ( bResult ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + if ( pRptModel ) + { + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + if ( !m_xReportComponent.is() ) + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + } + SetPropsFromRect(GetSnapRect()); + } + + return bResult; +} + +//---------------------------------------------------------------------------- +void OCustomShape::SetObjectItemHelper(const SfxPoolItem& rItem) +{ + SetObjectItem(rItem); + // TODO + //getSectionWindow()->getView()->AdjustMarkHdl(); +} + +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySet> OCustomShape::getAwtComponent() +{ + return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY); +} + +//---------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OCustomShape::getUnoShape() +{ + uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this ); + if ( !m_xReportComponent.is() ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + m_xReportComponent.set(xShape,uno::UNO_QUERY); + } + return xShape; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +TYPEINIT1(OUnoObject, SdrUnoObj); +DBG_NAME( rpt_OUnoObject ); +//---------------------------------------------------------------------------- +OUnoObject::OUnoObject(const ::rtl::OUString& _sComponentName + ,const ::rtl::OUString& rModelName + ,sal_uInt16 _nObjectType) + :SdrUnoObj(rModelName, sal_True) + ,OObjectBase(_sComponentName) + ,m_nObjectType(_nObjectType) +{ + DBG_CTOR( rpt_OUnoObject, NULL); + if ( rModelName.getLength() ) + impl_initializeModel_nothrow(); +} +//---------------------------------------------------------------------------- +OUnoObject::OUnoObject(const uno::Reference< report::XReportComponent>& _xComponent + ,const ::rtl::OUString& rModelName + ,sal_uInt16 _nObjectType) + :SdrUnoObj(rModelName, sal_True) + ,OObjectBase(_xComponent) + ,m_nObjectType(_nObjectType) +{ + DBG_CTOR( rpt_OUnoObject, NULL); + impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) ); + + if ( rModelName.getLength() ) + impl_initializeModel_nothrow(); + + if ( rModelName.getLength() ) + impl_initializeModel_nothrow(); +} +//---------------------------------------------------------------------------- +OUnoObject::~OUnoObject() +{ + DBG_DTOR( rpt_OUnoObject, NULL); +} +// ----------------------------------------------------------------------------- +void OUnoObject::impl_initializeModel_nothrow() +{ + try + { + Reference< XFormattedField > xFormatted( m_xReportComponent, UNO_QUERY ); + if ( xFormatted.is() ) + { + const Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW ); + const ::rtl::OUString sTreatAsNumberProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TreatAsNumber" ) ); + xModelProps->setPropertyValue( sTreatAsNumberProperty, makeAny( sal_False ) ); + xModelProps->setPropertyValue( PROPERTY_VERTICALALIGN,m_xReportComponent->getPropertyValue(PROPERTY_VERTICALALIGN)); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} +// ----------------------------------------------------------------------------- +void OUnoObject::impl_setReportComponent_nothrow() +{ + if ( m_xReportComponent.is() ) + return; + + OReportModel* pReportModel = static_cast<OReportModel*>(GetModel()); + OSL_ENSURE( pReportModel, "OUnoObject::impl_setReportComponent_nothrow: no report model!" ); + if ( !pReportModel ) + return; + + OXUndoEnvironment::OUndoEnvLock aLock( pReportModel->GetUndoEnv() ); + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + + impl_initializeModel_nothrow(); +} +// ----------------------------------------------------------------------------- +UINT16 OUnoObject::GetObjIdentifier() const +{ + return UINT16(m_nObjectType); +} +//---------------------------------------------------------------------------- +UINT32 OUnoObject::GetObjInventor() const +{ + return ReportInventor; +} +//---------------------------------------------------------------------------- +SdrPage* OUnoObject::GetImplPage() const +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + return GetPage(); +} +//---------------------------------------------------------------------------- +void OUnoObject::SetSnapRectImpl(const Rectangle& _rRect) +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + SetSnapRect( _rRect ); +} +//---------------------------------------------------------------------------- +sal_Int32 OUnoObject::GetStep() const +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + // get step property + sal_Int32 nStep = 0; + OSL_ENSURE(0,"Who called me!"); + return nStep; +} + +//---------------------------------------------------------------------------- +void OUnoObject::NbcMove( const Size& rSize ) +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + + if ( m_bIsListening ) + { + // stop listening + OObjectBase::EndListening(sal_False); + + bool bPositionFixed = false; + Size aUndoSize(0,0); + bool bUndoMode = false; + if ( m_xReportComponent.is() ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + if (pRptModel->GetUndoEnv().IsUndoMode()) + { + // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode + bUndoMode = true; + } + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + + // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point? + int nNewX = m_xReportComponent->getPositionX() + rSize.A(); + // can this hinder us to set components outside the area? + // if (nNewX < 0) + // { + // nNewX = 0; + // } + m_xReportComponent->setPositionX(nNewX); + int nNewY = m_xReportComponent->getPositionY() + rSize.B(); + if (nNewY < 0 && !bUndoMode) + { + aUndoSize.B() = abs(nNewY); + bPositionFixed = true; + nNewY = 0; + } + m_xReportComponent->setPositionY(nNewY); + } + if (bPositionFixed) + { + // OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + // if ( pRptModel ) + // { + // if (! pRptModel->GetUndoEnv().IsLocked()) + // { + GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize)); + // } + // } + } + // set geometry properties + SetPropsFromRect(GetLogicRect()); + + // start listening + OObjectBase::StartListening(); + } + else + SdrUnoObj::NbcMove( rSize ); +} + +//---------------------------------------------------------------------------- + +void OUnoObject::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract) +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + SdrUnoObj::NbcResize( rRef, xFract, yFract ); + + // stop listening + OObjectBase::EndListening(sal_False); + + // set geometry properties + SetPropsFromRect(GetLogicRect()); + + // start listening + OObjectBase::StartListening(); +} +//---------------------------------------------------------------------------- +void OUnoObject::NbcSetLogicRect(const Rectangle& rRect) +{ + SdrUnoObj::NbcSetLogicRect(rRect); + // stop listening + OObjectBase::EndListening(sal_False); + + // set geometry properties + SetPropsFromRect(rRect); + + // start listening + OObjectBase::StartListening(); +} +//---------------------------------------------------------------------------- + +FASTBOOL OUnoObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + FASTBOOL bResult = SdrUnoObj::EndCreate(rStat, eCmd); + if ( bResult ) + { + impl_setReportComponent_nothrow(); + // set labels + if ( m_xReportComponent.is() ) + { + try + { + if ( supportsService( SERVICE_FIXEDTEXT ) ) + { + m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName(this)) ); + } + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + impl_initializeModel_nothrow(); + } + // set geometry properties + SetPropsFromRect(GetLogicRect()); + } + + return bResult; +} +//---------------------------------------------------------------------------- +::rtl::OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj) +{ + sal_uInt16 nResId = 0; + ::rtl::OUString aDefaultName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HERE WE HAVE TO INSERT OUR NAME!")); + if ( _pObj->supportsService( SERVICE_FIXEDTEXT ) ) + { + nResId = RID_STR_CLASS_FIXEDTEXT; + } + else if ( _pObj->supportsService( SERVICE_FIXEDLINE ) ) + { + nResId = RID_STR_CLASS_FIXEDLINE; + } + else if ( _pObj->supportsService( SERVICE_IMAGECONTROL ) ) + { + nResId = RID_STR_CLASS_IMAGECONTROL; + } + else if ( _pObj->supportsService( SERVICE_FORMATTEDFIELD ) ) + { + nResId = RID_STR_CLASS_FORMATTEDFIELD; + } + + if (nResId) + aDefaultName = ::rtl::OUString( String(ModuleRes(nResId)) ); + + return aDefaultName; +} + +// ----------------------------------------------------------------------------- +void OUnoObject::_propertyChange( const beans::PropertyChangeEvent& evt ) throw( uno::RuntimeException) +{ + DBG_CHKTHIS( rpt_OUnoObject,NULL); + OObjectBase::_propertyChange(evt); + if (isListening()) + { + if ( evt.PropertyName == PROPERTY_CHARCOLOR ) + { + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() ) + { + OObjectBase::EndListening(sal_False); + try + { + xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue); + } + catch(uno::Exception&) + { + } + OObjectBase::StartListening(); + } + } + else if ( evt.PropertyName == PROPERTY_NAME ) + { + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) ) + { + // get old name + ::rtl::OUString aOldName; + evt.OldValue >>= aOldName; + + // get new name + ::rtl::OUString aNewName; + evt.NewValue >>= aNewName; + + if ( !aNewName.equals(aOldName) ) + { + // set old name property + OObjectBase::EndListening(sal_False); + if ( m_xMediator.is() ) + m_xMediator.get()->stopListening(); + try + { + xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue ); + } + catch(uno::Exception&) + { + } + if ( m_xMediator.is() ) + m_xMediator.get()->startListening(); + OObjectBase::StartListening(); + } + } + } + } +} +// ----------------------------------------------------------------------------- +void OUnoObject::CreateMediator(sal_Bool _bReverse) +{ + if ( !m_xMediator.is() ) + { + impl_setReportComponent_nothrow(); + + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( !m_xMediator.is() && m_xReportComponent.is() && xControlModel.is() ) + m_xMediator = TMediator::createFromQuery(new OPropertyMediator(m_xReportComponent.get(),xControlModel,getPropertyNameMap(GetObjIdentifier()),_bReverse)); + OObjectBase::StartListening(); + } +} +// ----------------------------------------------------------------------------- +uno::Reference< beans::XPropertySet> OUnoObject::getAwtComponent() +{ + return Reference<XPropertySet>(GetUnoControlModel(),uno::UNO_QUERY); +} + +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OUnoObject::getUnoShape() +{ + return OObjectBase::getUnoShapeOf( *this ); +} +// ----------------------------------------------------------------------------- +SdrObject* OUnoObject::Clone() const +{ + SdrObject* pClone = SdrUnoObj::Clone(); + if ( pClone ) + { + Reference<XPropertySet> xSource(const_cast<OUnoObject*>(this)->getUnoShape(),uno::UNO_QUERY); + Reference<XPropertySet> xDest(pClone->getUnoShape(),uno::UNO_QUERY); + if ( xSource.is() && xDest.is() ) + comphelper::copyProperties(xSource.get(),xDest.get()); + } // if ( pClone ) + return pClone; +} +//---------------------------------------------------------------------------- +// OOle2Obj +//---------------------------------------------------------------------------- +TYPEINIT1(OOle2Obj, SdrOle2Obj); +DBG_NAME( rpt_OOle2Obj ); +OOle2Obj::OOle2Obj(const uno::Reference< report::XReportComponent>& _xComponent,UINT16 _nType) + :SdrOle2Obj() + ,OObjectBase(_xComponent) + ,m_nType(_nType) + ,m_bOnlyOnce(true) +{ + DBG_CTOR( rpt_OOle2Obj, NULL); + + impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) ); + m_bIsListening = sal_True; +} +//---------------------------------------------------------------------------- +OOle2Obj::OOle2Obj(const ::rtl::OUString& _sComponentName,UINT16 _nType) + :SdrOle2Obj() + ,OObjectBase(_sComponentName) + ,m_nType(_nType) + ,m_bOnlyOnce(true) +{ + DBG_CTOR( rpt_OOle2Obj, NULL); + m_bIsListening = sal_True; +} +//---------------------------------------------------------------------------- +OOle2Obj::~OOle2Obj() +{ + DBG_DTOR( rpt_OOle2Obj, NULL); +} +// ----------------------------------------------------------------------------- +UINT16 OOle2Obj::GetObjIdentifier() const +{ + return m_nType; +} +//---------------------------------------------------------------------------- +UINT32 OOle2Obj::GetObjInventor() const +{ + return ReportInventor; +} +//---------------------------------------------------------------------------- +SdrPage* OOle2Obj::GetImplPage() const +{ + DBG_CHKTHIS( rpt_OOle2Obj,NULL); + return GetPage(); +} +//---------------------------------------------------------------------------- +void OOle2Obj::SetSnapRectImpl(const Rectangle& _rRect) +{ + DBG_CHKTHIS( rpt_OOle2Obj,NULL); + SetSnapRect( _rRect ); +} +//---------------------------------------------------------------------------- +sal_Int32 OOle2Obj::GetStep() const +{ + DBG_CHKTHIS( rpt_OOle2Obj,NULL); + // get step property + sal_Int32 nStep = 0; + OSL_ENSURE(0,"Who called me!"); + return nStep; +} + +//---------------------------------------------------------------------------- +void OOle2Obj::NbcMove( const Size& rSize ) +{ + DBG_CHKTHIS( rpt_OOle2Obj,NULL); + + if ( m_bIsListening ) + { + // stop listening + OObjectBase::EndListening(sal_False); + + if ( m_xReportComponent.is() ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + m_xReportComponent->setPositionX(m_xReportComponent->getPositionX() + rSize.A()); + m_xReportComponent->setPositionY(m_xReportComponent->getPositionY() + rSize.B()); + } + + // set geometry properties + SetPropsFromRect(GetLogicRect()); + + // start listening + OObjectBase::StartListening(); + } + else + SdrOle2Obj::NbcMove( rSize ); +} + +//---------------------------------------------------------------------------- + +void OOle2Obj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract) +{ + DBG_CHKTHIS( rpt_OOle2Obj,NULL); + SdrOle2Obj::NbcResize( rRef, xFract, yFract ); + + // stop listening + OObjectBase::EndListening(sal_False); + + // set geometry properties + SetPropsFromRect(GetLogicRect()); + + // start listening + OObjectBase::StartListening(); +} +//---------------------------------------------------------------------------- +void OOle2Obj::NbcSetLogicRect(const Rectangle& rRect) +{ + SdrOle2Obj::NbcSetLogicRect(rRect); + // stop listening + OObjectBase::EndListening(sal_False); + + // set geometry properties + SetPropsFromRect(rRect); + + // start listening + OObjectBase::StartListening(); +} +//---------------------------------------------------------------------------- + +FASTBOOL OOle2Obj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) +{ + DBG_CHKTHIS( rpt_OOle2Obj,NULL); + FASTBOOL bResult = SdrOle2Obj::EndCreate(rStat, eCmd); + if ( bResult ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + if ( pRptModel ) + { + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + if ( !m_xReportComponent.is() ) + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + } + // set geometry properties + SetPropsFromRect(GetLogicRect()); + } + + return bResult; +} + +uno::Reference< beans::XPropertySet> OOle2Obj::getAwtComponent() +{ + return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY); +} + +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OOle2Obj::getUnoShape() +{ + uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this ); + if ( !m_xReportComponent.is() ) + { + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + m_xReportComponent.set(xShape,uno::UNO_QUERY); + } + return xShape; +} +// ----------------------------------------------------------------------------- +uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const uno::Reference < embed::XEmbeddedObject >& _xObj) +{ + uno::Reference< chart2::data::XDatabaseDataProvider > xSource; + uno::Reference< embed::XComponentSupplier > xCompSupp(_xObj,uno::UNO_QUERY); + if( xCompSupp.is()) + { + uno::Reference< chart2::XChartDocument> xChartDoc( xCompSupp->getComponent(), uno::UNO_QUERY ); + if ( xChartDoc.is() ) + { + xSource.set(xChartDoc->getDataProvider(),uno::UNO_QUERY); + } + } // if( xCompSupp.is()) + return xSource; +} +// ----------------------------------------------------------------------------- +// Clone() soll eine komplette Kopie des Objektes erzeugen. +SdrObject* OOle2Obj::Clone() const +{ + OOle2Obj* pObj = static_cast<OOle2Obj*>(SdrOle2Obj::Clone()); + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + svt::EmbeddedObjectRef::TryRunningState( pObj->GetObjRef() ); + pObj->impl_createDataProvider_nothrow(pRptModel->getReportDefinition().get()); + + uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(GetObjRef()) ); + uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(pObj->GetObjRef()) ); + if ( xSource.is() && xDest.is() ) + comphelper::copyProperties(xSource.get(),xDest.get()); + + pObj->initializeChart(pRptModel->getReportDefinition().get()); + return pObj; +} +// ----------------------------------------------------------------------------- +void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XModel>& _xModel) +{ + try + { + uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); + uno::Reference< chart2::data::XDataReceiver > xReceiver; + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is()) + xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); + OSL_ASSERT( xReceiver.is()); + if( xReceiver.is() ) + { + uno::Reference< lang::XMultiServiceFactory> xFac(_xModel,uno::UNO_QUERY); + uno::Reference< chart2::data::XDatabaseDataProvider > xDataProvider( xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"))),uno::UNO_QUERY); + xReceiver->attachDataProvider( xDataProvider.get() ); + } // if( xReceiver.is() ) + } + catch(uno::Exception) + { + } +} +// ----------------------------------------------------------------------------- +void OOle2Obj::initializeOle() +{ + if ( m_bOnlyOnce ) + { + m_bOnlyOnce = false; + uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is() ) + { + uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY ); + if ( xChartProps.is() ) + xChartProps->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NullDate")),uno::makeAny(util::DateTime(0,0,0,0,1,1,1900))); + } + } +} +// ----------------------------------------------------------------------------- +void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel) +{ + uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); + uno::Reference< chart2::data::XDataReceiver > xReceiver; + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is()) + xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); + OSL_ASSERT( xReceiver.is()); + if( xReceiver.is() ) + { + // lock the model to suppress any internal updates + uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); + if( xChartModel.is() ) + xChartModel->lockControllers(); + + if ( !lcl_getDataProvider(xObj).is() ) + impl_createDataProvider_nothrow(_xModel); + + OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); + pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + xReceiver->setArguments( aArgs.getPropertyValues() ); + + if( xChartModel.is() ) + xChartModel->unlockControllers(); + } +} +// ----------------------------------------------------------------------------- +uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XReportDefinition>& _xReport) +{ + uno::Reference<container::XNameAccess> xStyles = _xReport->getStyleFamilies(); + uno::Reference<container::XNameAccess> xPageStyles(xStyles->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles"))),uno::UNO_QUERY); + + uno::Reference< style::XStyle> xReturn; + uno::Sequence< ::rtl::OUString> aSeq = xPageStyles->getElementNames(); + const ::rtl::OUString* pIter = aSeq.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); + for(;pIter != pEnd && !xReturn.is() ;++pIter) + { + uno::Reference< style::XStyle> xStyle(xPageStyles->getByName(*pIter),uno::UNO_QUERY); + if ( xStyle->isInUse() ) + xReturn = xStyle; + } + return xReturn; +} +//---------------------------------------------------------------------------- +//============================================================================ +} // rptui +//============================================================================ diff --git a/reportdesign/source/core/sdr/RptObjectListener.cxx b/reportdesign/source/core/sdr/RptObjectListener.cxx new file mode 100644 index 000000000000..64cd9d3dc8a3 --- /dev/null +++ b/reportdesign/source/core/sdr/RptObjectListener.cxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "RptObjectListener.hxx" +#include "RptObject.hxx" +#include "RptDef.hxx" + +namespace rptui +{ +//============================================================================ +// OObjectListener +//============================================================================ + +//---------------------------------------------------------------------------- +DBG_NAME(rpt_OObjectListener) +OObjectListener::OObjectListener(OObjectBase* _pObject) + :m_pObject(_pObject) +{ + DBG_CTOR(rpt_OObjectListener,NULL); +} + +//---------------------------------------------------------------------------- + +OObjectListener::~OObjectListener() +{ + DBG_DTOR(rpt_OObjectListener,NULL); +} + +// XEventListener +//---------------------------------------------------------------------------- + +void SAL_CALL OObjectListener::disposing( const ::com::sun::star::lang::EventObject& ) throw( ::com::sun::star::uno::RuntimeException) +{ + /* + // disconnect the listener + if (m_pObject) + { + (m_pObject->m_xPropertyChangeListener).clear(); + } + */ +} + +// XPropertyChangeListener +//---------------------------------------------------------------------------- + +void SAL_CALL OObjectListener::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException) +{ + m_pObject->_propertyChange( evt ); +} + +//---------------------------------------------------------------------------- + +//============================================================================ +// DlgEdHint +//============================================================================ + +TYPEINIT1( DlgEdHint, SfxHint ); + +//---------------------------------------------------------------------------- + +DlgEdHint::DlgEdHint( DlgEdHintKind eHint ) + :eHintKind( eHint ) +{ +} + +//---------------------------------------------------------------------------- +DlgEdHint::~DlgEdHint() +{ +} +//---------------------------------------------------------------------------- +} diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx new file mode 100644 index 000000000000..29f1109aeb6b --- /dev/null +++ b/reportdesign/source/core/sdr/RptPage.cxx @@ -0,0 +1,251 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "RptPage.hxx" +#include "RptModel.hxx" +#include "Section.hxx" +#include "RptObject.hxx" +#include <svx/unoapi.hxx> +#include <svx/unoshape.hxx> +#include "ReportDrawPage.hxx" + +namespace rptui +{ +using namespace ::com::sun::star; +TYPEINIT1( OReportPage, SdrPage ); + +//---------------------------------------------------------------------------- +DBG_NAME( rpt_OReportPage ) +OReportPage::OReportPage( OReportModel& _rModel + ,const uno::Reference< report::XSection >& _xSection + ,FASTBOOL bMasterPage ) + :SdrPage( _rModel, bMasterPage ) + ,rModel(_rModel) + ,m_xSection(_xSection) + ,m_bSpecialInsertMode(false) +{ + DBG_CTOR( rpt_OReportPage,NULL); +} + +//---------------------------------------------------------------------------- + +OReportPage::OReportPage( const OReportPage& rPage ) + :SdrPage( rPage ) + ,rModel(rPage.rModel) + ,m_xSection(rPage.m_xSection) + ,m_bSpecialInsertMode(rPage.m_bSpecialInsertMode) + ,m_aTemporaryObjectList(rPage.m_aTemporaryObjectList) +{ + DBG_CTOR( rpt_OReportPage,NULL); +} + +//---------------------------------------------------------------------------- + +OReportPage::~OReportPage() +{ + DBG_DTOR( rpt_OReportPage,NULL); +} + +//---------------------------------------------------------------------------- + +SdrPage* OReportPage::Clone() const +{ + DBG_CHKTHIS( rpt_OReportPage,NULL); + return new OReportPage( *this ); +} + +//---------------------------------------------------------------------------- +ULONG OReportPage::getIndexOf(const uno::Reference< report::XReportComponent >& _xObject) +{ + DBG_CHKTHIS( rpt_OReportPage,NULL); + ULONG nCount = GetObjCount(); + ULONG i = 0; + for (; i < nCount; ++i) + { + OObjectBase* pObj = dynamic_cast<OObjectBase*>(GetObj(i)); + OSL_ENSURE(pObj,"Invalid object found!"); + if ( pObj && pObj->getReportComponent() == _xObject ) + { + break; + } + } // for (; i < nCount; ++i) + return i; +} +//---------------------------------------------------------------------------- +void OReportPage::removeSdrObject(const uno::Reference< report::XReportComponent >& _xObject) +{ + DBG_CHKTHIS( rpt_OReportPage,NULL); + ULONG nPos = getIndexOf(_xObject); + if ( nPos < GetObjCount() ) + { + OObjectBase* pBase = dynamic_cast<OObjectBase*>(GetObj(nPos)); + OSL_ENSURE(pBase,"Why is this not a OObjectBase?"); + if ( pBase ) + pBase->EndListening(); + /*delete */RemoveObject(nPos); + } +} +// ----------------------------------------------------------------------------- +SdrObject* OReportPage::RemoveObject(ULONG nObjNum) +{ + SdrObject* pObj = SdrPage::RemoveObject(nObjNum); + if (getSpecialMode()) + { + return pObj; + } + + // this code is evil, but what else shall I do + reportdesign::OSection* pSection = reportdesign::OSection::getImplementation(m_xSection); + uno::Reference< drawing::XShape> xShape(pObj->getUnoShape(),uno::UNO_QUERY); + pSection->notifyElementRemoved(xShape); + if (pObj->ISA(OUnoObject)) + { + OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObj); + uno::Reference< container::XChild> xChild(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY); + if ( xChild.is() ) + xChild->setParent(NULL); + } + return pObj; +} +//---------------------------------------------------------------------------- +//namespace +//{ +// ::rtl::OUString lcl_getControlName(const uno::Reference< lang::XServiceInfo >& _xServiceInfo) +// { +// if ( _xServiceInfo->supportsService( SERVICE_FIXEDTEXT )) +// return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")); +// if ( _xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD )) +// return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField")); +// if ( _xServiceInfo->supportsService( SERVICE_IMAGECONTROL)) +// return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl")); +// +// return ::rtl::OUString(); +// } +//} +//---------------------------------------------------------------------------- +void OReportPage::insertObject(const uno::Reference< report::XReportComponent >& _xObject) +{ + DBG_CHKTHIS( rpt_OReportPage,NULL); + OSL_ENSURE(_xObject.is(),"Object is not valid to create a SdrObject!"); + if ( !_xObject.is() ) // || !m_pView ) + return; + ULONG nPos = getIndexOf(_xObject); + if ( nPos < GetObjCount() ) + return; // Object already in list + + SvxShape* pShape = SvxShape::getImplementation( _xObject ); + OObjectBase* pObject = pShape ? dynamic_cast< OObjectBase* >( pShape->GetSdrObject() ) : NULL; + OSL_ENSURE( pObject, "OReportPage::insertObject: no implementation object found for the given shape/component!" ); + if ( pObject ) + pObject->StartListening(); +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XSection > OReportPage::getSection() const +{ + return m_xSection; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface > OReportPage::createUnoPage() +{ + return static_cast<cppu::OWeakObject*>( new reportdesign::OReportDrawPage(this,m_xSection) ); +} +// ----------------------------------------------------------------------------- +void OReportPage::removeTempObject(SdrObject *_pToRemoveObj) +{ + if (_pToRemoveObj) + { + for (ULONG i=0;i<GetObjCount();i++) + { + SdrObject *aObj = GetObj(i); + if (aObj && aObj == _pToRemoveObj) + { + SdrObject* pObject = RemoveObject(i); + (void)pObject; + break; + // delete pObject; + } + } + } +} + +void OReportPage::resetSpecialMode() +{ + const sal_Bool bChanged = rModel.IsChanged(); + ::std::vector<SdrObject*>::iterator aIter = m_aTemporaryObjectList.begin(); + ::std::vector<SdrObject*>::iterator aEnd = m_aTemporaryObjectList.end(); + + for (; aIter != aEnd; ++aIter) + { + removeTempObject(*aIter); + } + m_aTemporaryObjectList.clear(); + rModel.SetChanged(bChanged); + + m_bSpecialInsertMode = false; +} +// ----------------------------------------------------------------------------- +void OReportPage::NbcInsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* pReason) +{ + SdrPage::NbcInsertObject(pObj, nPos, pReason); + + OUnoObject* pUnoObj = dynamic_cast< OUnoObject* >( pObj ); + if (getSpecialMode()) + { + m_aTemporaryObjectList.push_back(pObj); + return; + } + + if ( pUnoObj ) + { + pUnoObj->CreateMediator(); + uno::Reference< container::XChild> xChild(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY); + if ( xChild.is() && !xChild->getParent().is() ) + xChild->setParent(m_xSection); + } + + // this code is evil, but what else shall I do + reportdesign::OSection* pSection = reportdesign::OSection::getImplementation(m_xSection); + uno::Reference< drawing::XShape> xShape(pObj->getUnoShape(),uno::UNO_QUERY); + pSection->notifyElementAdded(xShape); + + //// check if we are a shape + //uno::Reference<beans::XPropertySet> xProp(xShape,uno::UNO_QUERY); + //if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID"))) ) + //{ + // // use MimeConfigurationHelper::GetStringClassIDRepresentation(MimeConfigurationHelper::GetSequenceClassID(SO3_SCH_OLE_EMBED_CLASSID_8)) + // xProp->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID")),uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("12dcae26-281f-416f-a234-c3086127382e")))); + //} + + // now that the shape is inserted into its structures, we can allow the OObjectBase + // to release the reference to it + OObjectBase* pObjectBase = dynamic_cast< OObjectBase* >( pObj ); + OSL_ENSURE( pObjectBase, "OReportPage::NbcInsertObject: what is being inserted here?" ); + if ( pObjectBase ) + pObjectBase->releaseUnoShape(); +} +//============================================================================ +} // rptui +//============================================================================ diff --git a/reportdesign/source/core/sdr/UndoActions.cxx b/reportdesign/source/core/sdr/UndoActions.cxx new file mode 100644 index 000000000000..d58fe62e974d --- /dev/null +++ b/reportdesign/source/core/sdr/UndoActions.cxx @@ -0,0 +1,449 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#include "UndoActions.hxx" +#include "UndoEnv.hxx" +#include "formatnormalizer.hxx" +#include "conditionupdater.hxx" +#include "corestrings.hrc" +#include "rptui_slotid.hrc" +#include "RptDef.hxx" +#include "ModuleHelper.hxx" +#include "RptObject.hxx" +#include "RptPage.hxx" +#include "RptResId.hrc" +#include "RptModel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +/** === end UNO includes === **/ + +#include <connectivity/dbtools.hxx> +#include <svl/smplhint.hxx> +#include <tools/diagnose_ex.h> +#include <comphelper/stl_types.hxx> +#include <vcl/svapp.hxx> +#include <dbaccess/singledoccontroller.hxx> +#include <svx/unoshape.hxx> +#include <vos/mutex.hxx> + +namespace rptui +{ + using namespace ::com::sun::star; + using namespace uno; + using namespace lang; + using namespace script; + using namespace beans; + using namespace awt; + using namespace util; + using namespace container; + using namespace report; +//---------------------------------------------------------------------------- +::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> OGroupHelper::getMemberFunction(const Reference< XSection >& _xSection) +{ + ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter); + uno::Reference< report::XGroup> xGroup = _xSection->getGroup(); + if ( xGroup->getHeaderOn() && xGroup->getHeader() == _xSection ) + pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader); + return pMemFunSection; +} +// ----------------------------------------------------------------------------- +::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> OReportHelper::getMemberFunction(const Reference< XSection >& _xSection) +{ + uno::Reference< report::XReportDefinition> xReportDefinition(_xSection->getReportDefinition()); + ::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> pMemFunSection = ::std::mem_fun(&OReportHelper::getReportFooter); + if ( xReportDefinition->getReportHeaderOn() && xReportDefinition->getReportHeader() == _xSection ) + pMemFunSection = ::std::mem_fun(&OReportHelper::getReportHeader); + else if ( xReportDefinition->getPageHeaderOn() && xReportDefinition->getPageHeader() == _xSection ) + pMemFunSection = ::std::mem_fun(&OReportHelper::getPageHeader); + else if ( xReportDefinition->getPageFooterOn() && xReportDefinition->getPageFooter() == _xSection ) + pMemFunSection = ::std::mem_fun(&OReportHelper::getPageFooter); + else if ( xReportDefinition->getDetail() == _xSection ) + pMemFunSection = ::std::mem_fun(&OReportHelper::getDetail); + return pMemFunSection; +} + +//------------------------------------------------------------------------------ +TYPEINIT1( OCommentUndoAction, SdrUndoAction ); +DBG_NAME(rpt_OCommentUndoAction) +//---------------------------------------------------------------------------- +OCommentUndoAction::OCommentUndoAction(SdrModel& _rMod,USHORT nCommentID) + :SdrUndoAction(_rMod) +{ + DBG_CTOR(rpt_OCommentUndoAction,NULL); + m_pController = static_cast< OReportModel& >( _rMod ).getController(); + if ( nCommentID ) + m_strComment = String(ModuleRes(nCommentID)); +} +OCommentUndoAction::~OCommentUndoAction() +{ + DBG_DTOR(rpt_OCommentUndoAction,NULL); +} +//---------------------------------------------------------------------------- +void OCommentUndoAction::Undo() +{ +} +//---------------------------------------------------------------------------- +void OCommentUndoAction::Redo() +{ +} +DBG_NAME( rpt_OUndoContainerAction ); +//------------------------------------------------------------------------------ +OUndoContainerAction::OUndoContainerAction(SdrModel& _rMod + ,Action _eAction + ,const uno::Reference< container::XIndexContainer > _xContainer + ,const Reference< XInterface > & xElem + ,USHORT _nCommentId) + :OCommentUndoAction(_rMod,_nCommentId) + ,m_xElement(xElem) + ,m_xContainer(_xContainer) + ,m_eAction( _eAction ) +{ + DBG_CTOR( rpt_OUndoContainerAction,NULL); + // normalize + if ( m_eAction == Removed ) + // we now own the element + m_xOwnElement = m_xElement; +} +//------------------------------------------------------------------------------ +OUndoContainerAction::~OUndoContainerAction() +{ + // if we own the object .... + Reference< XComponent > xComp( m_xOwnElement, UNO_QUERY ); + if ( xComp.is() ) + { + // and the object does not have a parent + Reference< XChild > xChild( m_xOwnElement, UNO_QUERY ); + if ( xChild.is() && !xChild->getParent().is() ) + { + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + rEnv.RemoveElement( m_xOwnElement ); + +#if OSL_DEBUG_LEVEL > 0 + SvxShape* pShape = SvxShape::getImplementation( xChild ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL; + OSL_ENSURE( pObject ? pShape->HasSdrObjectOwnership() && !pObject->IsInserted() : true , + "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" ); +#endif + // -> dispose it + try + { + comphelper::disposeComponent( xComp ); + } + catch ( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + DBG_DTOR( rpt_OUndoContainerAction,NULL); +} +//------------------------------------------------------------------------------ +void OUndoContainerAction::implReInsert( ) SAL_THROW( ( Exception ) ) +{ + if ( m_xContainer.is() ) + { + // insert the element + m_xContainer->insertByIndex( m_xContainer->getCount(),uno::makeAny(m_xElement) ); + } + // we don't own the object anymore + m_xOwnElement = NULL; +} + +//------------------------------------------------------------------------------ +void OUndoContainerAction::implReRemove( ) SAL_THROW( ( Exception ) ) +{ + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + try + { + OXUndoEnvironment::OUndoEnvLock aLock(rEnv); + if ( m_xContainer.is() ) + { + const sal_Int32 nCount = m_xContainer->getCount(); + for (sal_Int32 i = 0; i < nCount; ++i) + { + uno::Reference< uno::XInterface> xObj(m_xContainer->getByIndex(i),uno::UNO_QUERY); + if ( xObj == m_xElement ) + { + m_xContainer->removeByIndex( i ); + break; + } + } + } + } + catch(uno::Exception&){} + // from now on, we own this object + m_xOwnElement = m_xElement; +} + +//------------------------------------------------------------------------------ +void OUndoContainerAction::Undo() +{ + if ( m_xElement.is() ) + { + // prevents that an undo action will be created for elementInserted + try + { + switch ( m_eAction ) + { + case Inserted: + implReRemove(); + break; + + case Removed: + implReInsert(); + break; + default: + OSL_ENSURE(0,"Illegal case value"); + break; + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "OUndoContainerAction::Undo: caught an exception!" ); + } + } +} + +//------------------------------------------------------------------------------ +void OUndoContainerAction::Redo() +{ + if ( m_xElement.is() ) + { + try + { + switch ( m_eAction ) + { + case Inserted: + implReInsert(); + break; + + case Removed: + implReRemove(); + break; + default: + OSL_ENSURE(0,"Illegal case value"); + break; + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "OUndoContainerAction::Redo: caught an exception!" ); + } + } +} +// ----------------------------------------------------------------------------- +OUndoGroupSectionAction::OUndoGroupSectionAction(SdrModel& _rMod + ,Action _eAction + ,::std::mem_fun_t< uno::Reference< report::XSection > + ,OGroupHelper> _pMemberFunction + ,const uno::Reference< report::XGroup >& _xGroup + ,const Reference< XInterface > & xElem + ,USHORT _nCommentId) +:OUndoContainerAction(_rMod,_eAction,NULL,xElem,_nCommentId) +,m_aGroupHelper(_xGroup) +,m_pMemberFunction(_pMemberFunction) +{ +} +//------------------------------------------------------------------------------ +void OUndoGroupSectionAction::implReInsert( ) SAL_THROW( ( Exception ) ) +{ + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + try + { + OXUndoEnvironment::OUndoEnvLock aLock(rEnv); + uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aGroupHelper); + if ( xSection.is() ) + xSection->add(uno::Reference< drawing::XShape>(m_xElement,uno::UNO_QUERY)); + } + catch(uno::Exception&){} + + // we don't own the object anymore + m_xOwnElement = NULL; +} + +//------------------------------------------------------------------------------ +void OUndoGroupSectionAction::implReRemove( ) SAL_THROW( ( Exception ) ) +{ + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + try + { + OXUndoEnvironment::OUndoEnvLock aLock(rEnv); + uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aGroupHelper); + if ( xSection.is() ) + xSection->remove(uno::Reference< drawing::XShape>(m_xElement,uno::UNO_QUERY)); + } + catch(uno::Exception&){} + + // from now on, we own this object + m_xOwnElement = m_xElement; +} +//---------------------------------------------------------------------------- +OUndoReportSectionAction::OUndoReportSectionAction(SdrModel& _rMod + ,Action _eAction + ,::std::mem_fun_t< uno::Reference< report::XSection > + ,OReportHelper> _pMemberFunction + ,const uno::Reference< report::XReportDefinition >& _xReport + ,const Reference< XInterface > & xElem + ,USHORT _nCommentId) +:OUndoContainerAction(_rMod,_eAction,NULL,xElem,_nCommentId) +,m_aReportHelper(_xReport) +,m_pMemberFunction(_pMemberFunction) +{ +} +//------------------------------------------------------------------------------ +void OUndoReportSectionAction::implReInsert( ) SAL_THROW( ( Exception ) ) +{ + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + try + { + OXUndoEnvironment::OUndoEnvLock aLock(rEnv); + uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aReportHelper); + if ( xSection.is() ) + { + uno::Reference< drawing::XShape> xShape(m_xElement,uno::UNO_QUERY_THROW); + awt::Point aPos = xShape->getPosition(); + awt::Size aSize = xShape->getSize(); + xSection->add(xShape); + xShape->setPosition( aPos ); + xShape->setSize( aSize ); + } + } + catch(uno::Exception&){} + // we don't own the object anymore + m_xOwnElement = NULL; +} + +//------------------------------------------------------------------------------ +void OUndoReportSectionAction::implReRemove( ) SAL_THROW( ( Exception ) ) +{ + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + try + { + OXUndoEnvironment::OUndoEnvLock aLock(rEnv); + uno::Reference< report::XSection> xSection = m_pMemberFunction(&m_aReportHelper); + if ( xSection.is() ) + xSection->remove(uno::Reference< drawing::XShape>(m_xElement,uno::UNO_QUERY)); + } + catch(uno::Exception&){} + // from now on, we own this object + m_xOwnElement = m_xElement; +} +//------------------------------------------------------------------------------ +ORptUndoPropertyAction::ORptUndoPropertyAction(SdrModel& rNewMod, const PropertyChangeEvent& evt) + :OCommentUndoAction(rNewMod,0) + ,m_xObj(evt.Source, UNO_QUERY) + ,m_aPropertyName(evt.PropertyName) + ,m_aNewValue(evt.NewValue) + ,m_aOldValue(evt.OldValue) +{ +} +//------------------------------------------------------------------------------ +void ORptUndoPropertyAction::Undo() +{ + setProperty(sal_True); +} + +//------------------------------------------------------------------------------ +void ORptUndoPropertyAction::Redo() +{ + setProperty(sal_False); +} +// ----------------------------------------------------------------------------- +Reference< XPropertySet> ORptUndoPropertyAction::getObject() +{ + return m_xObj; +} +// ----------------------------------------------------------------------------- +void ORptUndoPropertyAction::setProperty(sal_Bool _bOld) +{ + Reference< XPropertySet> xObj = getObject(); + + if (xObj.is() ) + { + try + { + xObj->setPropertyValue( m_aPropertyName, _bOld ? m_aOldValue : m_aNewValue ); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "ORptUndoPropertyAction::Redo: caught an exception!" ); + } + } +} + +//------------------------------------------------------------------------------ +String ORptUndoPropertyAction::GetComment() const +{ + String aStr(ModuleRes(RID_STR_UNDO_PROPERTY)); + + aStr.SearchAndReplace( '#', m_aPropertyName ); + return aStr; +} +// ----------------------------------------------------------------------------- +OUndoPropertyGroupSectionAction::OUndoPropertyGroupSectionAction(SdrModel& _rMod + ,const PropertyChangeEvent& evt + ,::std::mem_fun_t< uno::Reference< report::XSection > + ,OGroupHelper> _pMemberFunction + ,const uno::Reference< report::XGroup >& _xGroup + ) +:ORptUndoPropertyAction(_rMod,evt) +,m_aGroupHelper(_xGroup) +,m_pMemberFunction(_pMemberFunction) +{ +} +// ----------------------------------------------------------------------------- +Reference< XPropertySet> OUndoPropertyGroupSectionAction::getObject() +{ + return m_pMemberFunction(&m_aGroupHelper).get(); +} +// ----------------------------------------------------------------------------- +OUndoPropertyReportSectionAction::OUndoPropertyReportSectionAction(SdrModel& _rMod + ,const PropertyChangeEvent& evt + ,::std::mem_fun_t< uno::Reference< report::XSection > + ,OReportHelper> _pMemberFunction + ,const uno::Reference< report::XReportDefinition >& _xReport + ) +:ORptUndoPropertyAction(_rMod,evt) +,m_aReportHelper(_xReport) +,m_pMemberFunction(_pMemberFunction) +{ +} +// ----------------------------------------------------------------------------- +Reference< XPropertySet> OUndoPropertyReportSectionAction::getObject() +{ + return m_pMemberFunction(&m_aReportHelper).get(); +} +//============================================================================ +} // rptui +//============================================================================ + diff --git a/reportdesign/source/core/sdr/UndoEnv.cxx b/reportdesign/source/core/sdr/UndoEnv.cxx new file mode 100644 index 000000000000..f4dd0a7f8645 --- /dev/null +++ b/reportdesign/source/core/sdr/UndoEnv.cxx @@ -0,0 +1,705 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "UndoActions.hxx" +#include "UndoEnv.hxx" +#include "formatnormalizer.hxx" +#include "conditionupdater.hxx" +#include "corestrings.hrc" +#include "rptui_slotid.hrc" +#include "RptDef.hxx" +#include "ModuleHelper.hxx" +#include "RptObject.hxx" +#include "RptPage.hxx" +#include "RptResId.hrc" +#include "RptModel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/beans/XIntrospectionAccess.hpp> +#include <com/sun/star/beans/XIntrospection.hpp> +/** === end UNO includes === **/ + +#include <connectivity/dbtools.hxx> +#include <svl/smplhint.hxx> +#include <tools/diagnose_ex.h> +#include <comphelper/stl_types.hxx> +#include <comphelper/componentcontext.hxx> +#include <vcl/svapp.hxx> +#include <dbaccess/singledoccontroller.hxx> +#include <svx/unoshape.hxx> +#include <vos/mutex.hxx> + +namespace rptui +{ + using namespace ::com::sun::star; + using namespace uno; + using namespace lang; + using namespace script; + using namespace beans; + using namespace awt; + using namespace util; + using namespace container; + using namespace report; +//---------------------------------------------------------------------------- + + +struct PropertyInfo +{ + bool bIsReadonlyOrTransient; + + PropertyInfo() + :bIsReadonlyOrTransient( false ) + { + } + + PropertyInfo( const bool i_bIsTransientOrReadOnly ) + :bIsReadonlyOrTransient( i_bIsTransientOrReadOnly ) + { + } +}; + +typedef ::std::hash_map< ::rtl::OUString, PropertyInfo, ::rtl::OUStringHash > PropertiesInfo; + +struct ObjectInfo +{ + PropertiesInfo aProperties; + Reference< XPropertySet > xPropertyIntrospection; + + ObjectInfo() + :aProperties() + ,xPropertyIntrospection() + { + } +}; + +typedef ::std::map< Reference< XPropertySet >, ObjectInfo, ::comphelper::OInterfaceCompare< XPropertySet > > PropertySetInfoCache; + +// ----------------------------------------------------------------------------- + +class OXUndoEnvironmentImpl +{ + OXUndoEnvironmentImpl(OXUndoEnvironmentImpl&); + void operator =(OXUndoEnvironmentImpl&); +public: + OReportModel& m_rModel; + PropertySetInfoCache m_aPropertySetCache; + FormatNormalizer m_aFormatNormalizer; + ConditionUpdater m_aConditionUpdater; + ::osl::Mutex m_aMutex; + ::std::vector< uno::Reference< container::XChild> > m_aSections; + Reference< XIntrospection > m_xIntrospection; + oslInterlockedCount m_nLocks; + sal_Bool m_bReadOnly; + sal_Bool m_bIsUndo; + + OXUndoEnvironmentImpl(OReportModel& _rModel); +}; + +OXUndoEnvironmentImpl::OXUndoEnvironmentImpl(OReportModel& _rModel) : m_rModel(_rModel) + ,m_aFormatNormalizer( _rModel ) + ,m_aConditionUpdater() + ,m_nLocks(0) + ,m_bReadOnly(sal_False) + ,m_bIsUndo(sal_False) +{ +} + +//------------------------------------------------------------------------------ +DBG_NAME( rpt_OXUndoEnvironment ); +//------------------------------------------------------------------------------ +OXUndoEnvironment::OXUndoEnvironment(OReportModel& _rModel) + :m_pImpl(new OXUndoEnvironmentImpl(_rModel) ) +{ + DBG_CTOR( rpt_OXUndoEnvironment,NULL); + StartListening(m_pImpl->m_rModel); +} + +//------------------------------------------------------------------------------ +OXUndoEnvironment::~OXUndoEnvironment() +{ + DBG_DTOR( rpt_OXUndoEnvironment,NULL); +} +// ----------------------------------------------------------------------------- +void OXUndoEnvironment::Lock() +{ + OSL_ENSURE(m_refCount,"Illegal call to dead object!"); + osl_incrementInterlockedCount( &m_pImpl->m_nLocks ); +} +void OXUndoEnvironment::UnLock() +{ + OSL_ENSURE(m_refCount,"Illegal call to dead object!"); + + osl_decrementInterlockedCount( &m_pImpl->m_nLocks ); +} +sal_Bool OXUndoEnvironment::IsLocked() const { return m_pImpl->m_nLocks != 0; } +// ----------------------------------------------------------------------------- +void OXUndoEnvironment::RemoveSection(OReportPage* _pPage) +{ + if ( _pPage ) + { + Reference< XInterface > xSection(_pPage->getSection()); + if ( xSection.is() ) + RemoveElement( xSection ); + } +} +//------------------------------------------------------------------------------ +void OXUndoEnvironment::Clear(const Accessor& /*_r*/) +{ + OUndoEnvLock aLock(*this); + +#if OSL_DEBUG_LEVEL > 0 + // TODO: LLA->OJ please describe what you are doing in this code fragment. + PropertySetInfoCache::iterator aIter = m_pImpl->m_aPropertySetCache.begin(); + PropertySetInfoCache::iterator aEnd = m_pImpl->m_aPropertySetCache.end(); + int ndbg_len = m_pImpl->m_aPropertySetCache.size(); + ndbg_len = ndbg_len; + for (int idbg_ = 0; aIter != aEnd; ++aIter,++idbg_) + { + uno::Reference<beans::XPropertySet> xProp(aIter->first,uno::UNO_QUERY); + xProp->getPropertySetInfo(); + int nlen = aIter->second.aProperties.size(); + nlen = nlen; + } +#endif + m_pImpl->m_aPropertySetCache.clear(); + + sal_uInt16 nCount = m_pImpl->m_rModel.GetPageCount(); + sal_uInt16 i; + for (i = 0; i < nCount; i++) + { + OReportPage* pPage = PTR_CAST( OReportPage, m_pImpl->m_rModel.GetPage(i) ); + RemoveSection(pPage); + } + + nCount = m_pImpl->m_rModel.GetMasterPageCount(); + for (i = 0; i < nCount; i++) + { + OReportPage* pPage = PTR_CAST( OReportPage, m_pImpl->m_rModel.GetMasterPage(i) ); + RemoveSection(pPage); + } + + m_pImpl->m_aSections.clear(); + + if (IsListening(m_pImpl->m_rModel)) + EndListening(m_pImpl->m_rModel); +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::ModeChanged() +{ + m_pImpl->m_bReadOnly = !m_pImpl->m_bReadOnly; + + if (!m_pImpl->m_bReadOnly) + StartListening(m_pImpl->m_rModel); + else + EndListening(m_pImpl->m_rModel); +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) +{ + if (rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_MODECHANGED ) + ModeChanged(); +} +// ----------------------------------------------------------------------------- +// XEventListener +//------------------------------------------------------------------------------ +void SAL_CALL OXUndoEnvironment::disposing(const EventObject& e) throw( RuntimeException ) +{ + // check if it's an object we have cached informations about + Reference< XPropertySet > xSourceSet(e.Source, UNO_QUERY); + if ( xSourceSet.is() ) + { + uno::Reference< report::XSection> xSection(xSourceSet,uno::UNO_QUERY); + if ( xSection.is() ) + RemoveSection(xSection); + else + RemoveElement(xSourceSet); + /*if (!m_pImpl->m_aPropertySetCache.empty()) + m_pImpl->m_aPropertySetCache.erase(xSourceSet);*/ + } +} + +// XPropertyChangeListener +//------------------------------------------------------------------------------ +void SAL_CALL OXUndoEnvironment::propertyChange( const PropertyChangeEvent& _rEvent ) throw(uno::RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( m_pImpl->m_aMutex ); + + if ( IsLocked() ) + return; + + Reference< XPropertySet > xSet( _rEvent.Source, UNO_QUERY ); + if (!xSet.is()) + return; + + dbaui::OSingleDocumentController* pController = m_pImpl->m_rModel.getController(); + if ( !pController ) + return; + + // no Undo for transient and readonly props. + // let's see if we know something about the set +#if OSL_DEBUG_LEVEL > 0 + int nlen = m_pImpl->m_aPropertySetCache.size(); + nlen = nlen; +#endif + PropertySetInfoCache::iterator objectPos = m_pImpl->m_aPropertySetCache.find(xSet); + if (objectPos == m_pImpl->m_aPropertySetCache.end()) + { + objectPos = m_pImpl->m_aPropertySetCache.insert( PropertySetInfoCache::value_type( + xSet, ObjectInfo() + ) ).first; + DBG_ASSERT(objectPos != m_pImpl->m_aPropertySetCache.end(), "OXUndoEnvironment::propertyChange : just inserted it ... why it's not there ?"); + } + if ( objectPos == m_pImpl->m_aPropertySetCache.end() ) + return; + + // now we have access to the cached info about the set + // let's see what we know about the property + ObjectInfo& rObjectInfo = objectPos->second; + PropertiesInfo::iterator aPropertyPos = rObjectInfo.aProperties.find( _rEvent.PropertyName ); + if ( aPropertyPos == rObjectInfo.aProperties.end() ) + { // nothing 'til now ... have to change this .... + // the attributes + Reference< XPropertySetInfo > xPSI( xSet->getPropertySetInfo(), UNO_SET_THROW ); + INT32 nPropertyAttributes = 0; + try + { + if ( xPSI->hasPropertyByName( _rEvent.PropertyName ) ) + { + nPropertyAttributes = xPSI->getPropertyByName( _rEvent.PropertyName ).Attributes; + } + else + { + // it's perfectly valid for a component to notify a change in a property which it doesn't have - as long + // as it has an attribute with this name + if ( !rObjectInfo.xPropertyIntrospection.is() ) + { + if ( !m_pImpl->m_xIntrospection.is() ) + { + ::comphelper::ComponentContext aContext( m_pImpl->m_rModel.getController()->getORB() ); + OSL_VERIFY( aContext.createComponent( "com.sun.star.beans.Introspection", m_pImpl->m_xIntrospection ) ); + } + if ( m_pImpl->m_xIntrospection.is() ) + { + Reference< XIntrospectionAccess > xIntrospection( + m_pImpl->m_xIntrospection->inspect( makeAny( _rEvent.Source ) ), + UNO_SET_THROW + ); + rObjectInfo.xPropertyIntrospection.set( xIntrospection->queryAdapter( XPropertySet::static_type() ), UNO_QUERY_THROW ); + } + } + if ( rObjectInfo.xPropertyIntrospection.is() ) + { + xPSI.set( rObjectInfo.xPropertyIntrospection->getPropertySetInfo(), UNO_SET_THROW ); + nPropertyAttributes = xPSI->getPropertyByName( _rEvent.PropertyName ).Attributes; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + const bool bTransReadOnly = + ( ( nPropertyAttributes & PropertyAttribute::READONLY ) != 0 ) + || ( ( nPropertyAttributes & PropertyAttribute::TRANSIENT ) != 0 ); + + // insert the new entry + aPropertyPos = rObjectInfo.aProperties.insert( PropertiesInfo::value_type( + _rEvent.PropertyName, + PropertyInfo( bTransReadOnly ) + ) ).first; + DBG_ASSERT(aPropertyPos != rObjectInfo.aProperties.end(), "OXUndoEnvironment::propertyChange : just inserted it ... why it's not there ?"); + } + + implSetModified(); + + // now we have access to the cached info about the property affected + // and are able to decide wether or not we need an undo action + + // no UNDO for transient/readonly properties + if ( aPropertyPos->second.bIsReadonlyOrTransient ) + return; + + // give components with sub responsibilities a chance + m_pImpl->m_aFormatNormalizer.notifyPropertyChange( _rEvent ); + m_pImpl->m_aConditionUpdater.notifyPropertyChange( _rEvent ); + + aGuard.clear(); + // TODO: this is a potential race condition: two threads here could in theory + // add their undo actions out-of-order + + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ORptUndoPropertyAction* pUndo = NULL; + try + { + uno::Reference< report::XSection> xSection( xSet, uno::UNO_QUERY ); + if ( xSection.is() ) + { + uno::Reference< report::XGroup> xGroup = xSection->getGroup(); + if ( xGroup.is() ) + pUndo = new OUndoPropertyGroupSectionAction( m_pImpl->m_rModel, _rEvent, OGroupHelper::getMemberFunction( xSection ), xGroup ); + else + pUndo = new OUndoPropertyReportSectionAction( m_pImpl->m_rModel, _rEvent, OReportHelper::getMemberFunction( xSection ), xSection->getReportDefinition() ); + } + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( pUndo == NULL ) + pUndo = new ORptUndoPropertyAction( m_pImpl->m_rModel, _rEvent ); + + pController->addUndoActionAndInvalidate(pUndo); + pController->InvalidateAll(); +} +// ----------------------------------------------------------------------------- +::std::vector< uno::Reference< container::XChild> >::const_iterator OXUndoEnvironment::getSection(const Reference<container::XChild>& _xContainer) const +{ + ::std::vector< uno::Reference< container::XChild> >::const_iterator aFind = m_pImpl->m_aSections.end(); + if ( _xContainer.is() ) + { + aFind = ::std::find(m_pImpl->m_aSections.begin(),m_pImpl->m_aSections.end(),_xContainer); + + if ( aFind == m_pImpl->m_aSections.end() ) + { + Reference<container::XChild> xParent(_xContainer->getParent(),uno::UNO_QUERY); + aFind = getSection(xParent); + } + } + return aFind; +} +// XContainerListener +//------------------------------------------------------------------------------ +void SAL_CALL OXUndoEnvironment::elementInserted(const ContainerEvent& evt) throw(uno::RuntimeException) +{ + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); + + // neues Object zum lauschen + Reference< uno::XInterface > xIface( evt.Element, UNO_QUERY ); + if ( !IsLocked() ) + { + Reference< report::XReportComponent > xReportComponent( xIface, UNO_QUERY ); + if ( xReportComponent.is() ) + { + Reference< report::XSection > xContainer(evt.Source,uno::UNO_QUERY); + + ::std::vector< uno::Reference< container::XChild> >::const_iterator aFind = getSection(xContainer.get()); + + if ( aFind != m_pImpl->m_aSections.end() ) + { + OUndoEnvLock aLock(*this); + try + { + OReportPage* pPage = m_pImpl->m_rModel.getPage(uno::Reference< report::XSection>(*aFind,uno::UNO_QUERY)); + OSL_ENSURE(pPage,"No page could be found for section!"); + if ( pPage ) + pPage->insertObject(xReportComponent); + } + catch(uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + } + } + else + { + uno::Reference< report::XFunctions> xContainer(evt.Source,uno::UNO_QUERY); + if ( xContainer.is() ) + { + dbaui::OSingleDocumentController* pController = m_pImpl->m_rModel.getController(); + pController->addUndoActionAndInvalidate(new OUndoContainerAction(m_pImpl->m_rModel + ,rptui::Inserted + ,xContainer.get() + ,xIface + ,RID_STR_UNDO_ADDFUNCTION)); + } + } + } + + AddElement(xIface); + + implSetModified(); +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::implSetModified() +{ + //if ( !IsLocked() ) + m_pImpl->m_rModel.SetModified( sal_True ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OXUndoEnvironment::elementReplaced(const ContainerEvent& evt) throw(uno::RuntimeException) +{ + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); + + Reference< XInterface > xIface(evt.ReplacedElement,uno::UNO_QUERY); + OSL_ENSURE(xIface.is(), "OXUndoEnvironment::elementReplaced: invalid container notification!"); + RemoveElement(xIface); + + xIface.set(evt.Element,uno::UNO_QUERY); + AddElement(xIface); + + implSetModified(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OXUndoEnvironment::elementRemoved(const ContainerEvent& evt) throw(uno::RuntimeException) +{ + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); + + Reference< uno::XInterface > xIface( evt.Element, UNO_QUERY ); + if ( !IsLocked() ) + { + Reference< report::XSection > xContainer(evt.Source,uno::UNO_QUERY); + ::std::vector< uno::Reference< container::XChild> >::const_iterator aFind = getSection(xContainer.get()); + + Reference< report::XReportComponent > xReportComponent( xIface, UNO_QUERY ); + if ( aFind != m_pImpl->m_aSections.end() && xReportComponent.is() ) + { + OXUndoEnvironment::OUndoEnvLock aLock(*this); + try + { + OReportPage* pPage = m_pImpl->m_rModel.getPage(uno::Reference< report::XSection >( *aFind, uno::UNO_QUERY_THROW ) ); + OSL_ENSURE( pPage, "OXUndoEnvironment::elementRemoved: no page for the section!" ); + if ( pPage ) + pPage->removeSdrObject(xReportComponent); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + else + { + uno::Reference< report::XFunctions> xFunctions(evt.Source,uno::UNO_QUERY); + if ( xFunctions.is() ) + { + dbaui::OSingleDocumentController* pController = m_pImpl->m_rModel.getController(); + pController->addUndoActionAndInvalidate(new OUndoContainerAction(m_pImpl->m_rModel + ,rptui::Removed + ,xFunctions.get() + ,xIface + ,RID_STR_UNDO_ADDFUNCTION)); + } + } + } + + if ( xIface.is() ) + RemoveElement(xIface); + + implSetModified(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OXUndoEnvironment::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException) +{ + implSetModified(); +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::AddSection(const Reference< report::XSection > & _xSection) +{ + OUndoEnvLock aLock(*this); + try + { + uno::Reference<container::XChild> xChild = _xSection.get(); + uno::Reference<report::XGroup> xGroup(xChild->getParent(),uno::UNO_QUERY); + m_pImpl->m_aSections.push_back(xChild); + Reference< XInterface > xInt(_xSection); + AddElement(xInt); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::RemoveSection(const Reference< report::XSection > & _xSection) +{ + OUndoEnvLock aLock(*this); + try + { + uno::Reference<container::XChild> xChild(_xSection.get()); + m_pImpl->m_aSections.erase(::std::remove(m_pImpl->m_aSections.begin(),m_pImpl->m_aSections.end(), + xChild), m_pImpl->m_aSections.end()); + Reference< XInterface > xInt(_xSection); + RemoveElement(xInt); + } + catch(uno::Exception&){} +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::TogglePropertyListening(const Reference< XInterface > & Element) +{ + // am Container horchen + Reference< XIndexAccess > xContainer(Element, UNO_QUERY); + if (xContainer.is()) + { + Reference< XInterface > xInterface; + sal_Int32 nCount = xContainer->getCount(); + for(sal_Int32 i = 0;i != nCount;++i) + { + xInterface.set(xContainer->getByIndex( i ),uno::UNO_QUERY); + TogglePropertyListening(xInterface); + } + } + + Reference< XPropertySet > xSet(Element, UNO_QUERY); + if (xSet.is()) + { + if (!m_pImpl->m_bReadOnly) + xSet->addPropertyChangeListener( ::rtl::OUString(), this ); + else + xSet->removePropertyChangeListener( ::rtl::OUString(), this ); + } +} + + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::switchListening( const Reference< XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(()) +{ + OSL_PRECOND( _rxContainer.is(), "OXUndoEnvironment::switchListening: invalid container!" ); + if ( !_rxContainer.is() ) + return; + + try + { + // also handle all children of this element + Reference< XInterface > xInterface; + sal_Int32 nCount = _rxContainer->getCount(); + for(sal_Int32 i = 0;i != nCount;++i) + { + xInterface.set(_rxContainer->getByIndex( i ),uno::UNO_QUERY); + if ( _bStartListening ) + AddElement( xInterface ); + else + RemoveElement( xInterface ); + } + + // be notified of any changes in the container elements + Reference< XContainer > xSimpleContainer( _rxContainer, UNO_QUERY ); + // OSL_ENSURE( xSimpleContainer.is(), "OXUndoEnvironment::switchListening: how are we expected to be notified of changes in the container?" ); + if ( xSimpleContainer.is() ) + { + if ( _bStartListening ) + xSimpleContainer->addContainerListener( this ); + else + xSimpleContainer->removeContainerListener( this ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::switchListening( const Reference< XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(()) +{ + OSL_PRECOND( _rxObject.is(), "OXUndoEnvironment::switchListening: how should I listen at a NULL object?" ); + + try + { + if ( !m_pImpl->m_bReadOnly ) + { + Reference< XPropertySet > xProps( _rxObject, UNO_QUERY ); + if ( xProps.is() ) + { + if ( _bStartListening ) + xProps->addPropertyChangeListener( ::rtl::OUString(), this ); + else + xProps->removePropertyChangeListener( ::rtl::OUString(), this ); + } + } + + Reference< XModifyBroadcaster > xBroadcaster( _rxObject, UNO_QUERY ); + if ( xBroadcaster.is() ) + { + if ( _bStartListening ) + xBroadcaster->addModifyListener( this ); + else + xBroadcaster->removeModifyListener( this ); + } + } + catch( const Exception& ) + { + //OSL_ENSURE( sal_False, "OXUndoEnvironment::switchListening: caught an exception!" ); + } +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::AddElement(const Reference< XInterface >& _rxElement ) +{ + if ( !IsLocked() ) + m_pImpl->m_aFormatNormalizer.notifyElementInserted( _rxElement ); + + // if it's a container, start listening at all elements + Reference< XIndexAccess > xContainer( _rxElement, UNO_QUERY ); + if ( xContainer.is() ) + switchListening( xContainer, true ); + + switchListening( _rxElement, true ); +} + +//------------------------------------------------------------------------------ +void OXUndoEnvironment::RemoveElement(const Reference< XInterface >& _rxElement) +{ + uno::Reference<beans::XPropertySet> xProp(_rxElement,uno::UNO_QUERY); + if (!m_pImpl->m_aPropertySetCache.empty()) + m_pImpl->m_aPropertySetCache.erase(xProp); + switchListening( _rxElement, false ); + + Reference< XIndexAccess > xContainer( _rxElement, UNO_QUERY ); + if ( xContainer.is() ) + switchListening( xContainer, false ); +} + +void OXUndoEnvironment::SetUndoMode(sal_Bool _bUndo) +{ + m_pImpl->m_bIsUndo = _bUndo; +} + +sal_Bool OXUndoEnvironment::IsUndoMode() const +{ + return m_pImpl->m_bIsUndo; +} +//============================================================================ +} // rptui +//============================================================================ diff --git a/reportdesign/source/core/sdr/formatnormalizer.cxx b/reportdesign/source/core/sdr/formatnormalizer.cxx new file mode 100644 index 000000000000..e4817bbe9f44 --- /dev/null +++ b/reportdesign/source/core/sdr/formatnormalizer.cxx @@ -0,0 +1,279 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#include "formatnormalizer.hxx" +#include "RptModel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#include <com/sun/star/util/XNumberFormatTypes.hpp> +/** === end UNO includes === **/ + +#include <dbaccess/singledoccontroller.hxx> +#include <unotools/syslocale.hxx> +#include <connectivity/statementcomposer.hxx> +#include <connectivity/dbtools.hxx> +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace rptui +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::report::XReportDefinition; + using ::com::sun::star::report::XFormattedField; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::sdb::XSingleSelectQueryComposer; + using ::com::sun::star::sdbcx::XColumnsSupplier; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::sdb::XParametersSupplier; + using ::com::sun::star::sdbc::SQLException; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::util::XNumberFormatTypes; + using ::com::sun::star::uno::makeAny; + /** === end UNO using === **/ + + //==================================================================== + //= FormatNormalizer + //==================================================================== + DBG_NAME(rpt_FormatNormalizer) + //-------------------------------------------------------------------- + FormatNormalizer::FormatNormalizer( const OReportModel& _rModel ) + :m_rModel( _rModel ) + ,m_xReportDefinition( ) + ,m_bFieldListDirty( true ) + { + DBG_CTOR(rpt_FormatNormalizer,NULL); + } + + //-------------------------------------------------------------------- + FormatNormalizer::~FormatNormalizer() + { + DBG_DTOR(rpt_FormatNormalizer,NULL); + } + + //-------------------------------------------------------------------- + void FormatNormalizer::notifyPropertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) + { + if ( !impl_lateInit() ) + return; + + if ( ( _rEvent.Source == m_xReportDefinition ) && m_xReportDefinition.is() ) + { + impl_onDefinitionPropertyChange( _rEvent.PropertyName ); + return; + } + + Reference< XFormattedField > xFormatted( _rEvent.Source, UNO_QUERY ); + if ( xFormatted.is() ) + impl_onFormattedProperttyChange( xFormatted, _rEvent.PropertyName ); + } + + //-------------------------------------------------------------------- + void FormatNormalizer::notifyElementInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement ) + { + if ( !impl_lateInit() ) + return; + + Reference< XFormattedField > xFormatted( _rxElement, UNO_QUERY ); + if ( !xFormatted.is() ) + return; + + impl_adjustFormatToDataFieldType_nothrow( xFormatted ); + } + + //-------------------------------------------------------------------- + bool FormatNormalizer::impl_lateInit() + { + if ( m_xReportDefinition.is() ) + return true; + + m_xReportDefinition = m_rModel.getReportDefinition(); + return m_xReportDefinition.is(); + } + + //-------------------------------------------------------------------- + void FormatNormalizer::impl_onDefinitionPropertyChange( const ::rtl::OUString& _rChangedPropName ) + { + if ( !_rChangedPropName.equalsAscii( "Command" ) + && !_rChangedPropName.equalsAscii( "CommandType" ) + && !_rChangedPropName.equalsAscii( "EscapeProcessing" ) + ) + // nothing we're interested in + return; + m_bFieldListDirty = true; + } + + //-------------------------------------------------------------------- + void FormatNormalizer::impl_onFormattedProperttyChange( const Reference< XFormattedField >& _rxFormatted, const ::rtl::OUString& _rChangedPropName ) + { + if ( !_rChangedPropName.equalsAscii( "DataField" ) ) + // nothing we're interested in + return; + + impl_adjustFormatToDataFieldType_nothrow( _rxFormatted ); + } + + //-------------------------------------------------------------------- + namespace + { + void lcl_collectFields_throw( const Reference< XIndexAccess >& _rxColumns, FormatNormalizer::FieldList& _inout_rFields ) + { + try + { + sal_Int32 nCount( _rxColumns->getCount() ); + _inout_rFields.reserve( _inout_rFields.size() + (size_t)nCount ); + + Reference< XPropertySet > xColumn; + FormatNormalizer::Field aField; + + for ( sal_Int32 i=0; i<nCount; ++i ) + { + xColumn.set( _rxColumns->getByIndex( i ), UNO_QUERY_THROW ); + OSL_VERIFY( xColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= aField.sName ); + OSL_VERIFY( xColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= aField.nDataType ); + OSL_VERIFY( xColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) >>= aField.nScale ); + OSL_VERIFY( xColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsCurrency" ) ) ) >>= aField.bIsCurrency ); + _inout_rFields.push_back( aField ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + //-------------------------------------------------------------------- + bool FormatNormalizer::impl_ensureUpToDateFieldList_nothrow() + { + if ( !m_bFieldListDirty ) + return true; + m_aFields.resize( 0 ); + + OSL_PRECOND( m_xReportDefinition.is(), "FormatNormalizer::impl_ensureUpToDateFieldList_nothrow: no report definition!" ); + if ( !m_xReportDefinition.is() ) + return false; + + ::dbaui::OSingleDocumentController* pController( m_rModel.getController() ); + OSL_ENSURE( pController, "FormatNormalizer::impl_ensureUpToDateFieldList_nothrow: no controller? how can *this* happen?!" ); + if ( !pController ) + return false; + + try + { + ::dbtools::StatementComposer aComposer( pController->getConnection(), m_xReportDefinition->getCommand(), + m_xReportDefinition->getCommandType(), m_xReportDefinition->getEscapeProcessing() ); + + Reference< XSingleSelectQueryComposer > xComposer( aComposer.getComposer() ); + if ( !xComposer.is() ) + return false; + + + Reference< XColumnsSupplier > xSuppCols( xComposer, UNO_QUERY_THROW ); + Reference< XIndexAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW ); + lcl_collectFields_throw( xColumns, m_aFields ); + + Reference< XParametersSupplier > xSuppParams( xComposer, UNO_QUERY_THROW ); + Reference< XIndexAccess > xParams( xSuppParams->getParameters(), UNO_QUERY_THROW ); + lcl_collectFields_throw( xParams, m_aFields ); + } + catch( const SQLException& ) + { + // silence it. This might happen for instance when the user sets an non-existent table, + // or things like this + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + m_bFieldListDirty = false; + return true; + } + + //-------------------------------------------------------------------- + void FormatNormalizer::impl_adjustFormatToDataFieldType_nothrow( const Reference< XFormattedField >& _rxFormatted ) + { + if ( !impl_ensureUpToDateFieldList_nothrow() ) + // unable to obtain a recent field list + return; + + try + { + sal_Int32 nFormatKey = _rxFormatted->getFormatKey(); + if ( nFormatKey != 0 ) + // it's not the "standard numeric" format -> not interested in + return; + + ::rtl::OUString sDataField( _rxFormatted->getDataField() ); + const ::rtl::OUString sFieldPrefix( RTL_CONSTASCII_USTRINGPARAM( "field:[" ) ); + if ( sDataField.indexOf( sFieldPrefix ) != 0 ) + // not bound to a table field + // TODO: we might also do this kind of thing for functions and expressions ... + return; + if ( sDataField.getStr()[ sDataField.getLength() - 1 ] != ']' ) + { + // last character is not the closing brace + OSL_ENSURE( false, "FormatNormalizer::impl_adjustFormatToDataFieldType_nothrow: suspicious data field value!" ); + return; + } + sDataField = sDataField.copy( sFieldPrefix.getLength(), sDataField.getLength() - sFieldPrefix.getLength() - 1 ); + + FieldList::const_iterator field = m_aFields.begin(); + for ( ; field != m_aFields.end(); ++field ) + { + if ( field->sName == sDataField ) + break; + } + if ( field == m_aFields.end() ) + // unknown field + return; + + Reference< XNumberFormatsSupplier > xSuppNumFmts( _rxFormatted->getFormatsSupplier(), UNO_QUERY_THROW ); + Reference< XNumberFormatTypes > xNumFmtTypes( xSuppNumFmts->getNumberFormats(), UNO_QUERY_THROW ); + + nFormatKey = ::dbtools::getDefaultNumberFormat( field->nDataType, field->nScale, field->bIsCurrency, xNumFmtTypes, + SvtSysLocale().GetLocaleData().getLocale() ); + _rxFormatted->setFormatKey( nFormatKey ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + +//........................................................................ +} // namespace rptui +//........................................................................ diff --git a/reportdesign/source/core/sdr/formatnormalizer.hxx b/reportdesign/source/core/sdr/formatnormalizer.hxx new file mode 100644 index 000000000000..8577d276d4c8 --- /dev/null +++ b/reportdesign/source/core/sdr/formatnormalizer.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef REPORTDESIGN_FORMATNORMALIZER_HXX +#define REPORTDESIGN_FORMATNORMALIZER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/report/XReportDefinition.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/report/XFormattedField.hpp> +/** === end UNO includes === **/ + +#include <boost/noncopyable.hpp> + +#include <vector> + +//........................................................................ +namespace rptui +{ +//........................................................................ + + class OReportModel; + //==================================================================== + //= FormatNormalizer + //==================================================================== + class FormatNormalizer : public ::boost::noncopyable + { + public: + struct Field + { + ::rtl::OUString sName; + sal_Int32 nDataType; + sal_Int32 nScale; + sal_Bool bIsCurrency; + + Field() : sName(), nDataType( 0 ), nScale( 0 ), bIsCurrency( 0 ) { } + }; + typedef ::std::vector< Field > FieldList; + + private: + const OReportModel& m_rModel; + ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > m_xReportDefinition; + + /// is our field list dirty? + FieldList m_aFields; + bool m_bFieldListDirty; + + public: + FormatNormalizer( const OReportModel& _rModel ); + ~FormatNormalizer(); + + void notifyPropertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ); + void notifyElementInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement ); + + private: + bool impl_lateInit(); + + void impl_onDefinitionPropertyChange( const ::rtl::OUString& _rChangedPropName ); + void impl_onFormattedProperttyChange( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormattedField >& _rxFormatted, const ::rtl::OUString& _rChangedPropName ); + + bool impl_ensureUpToDateFieldList_nothrow(); + + void impl_adjustFormatToDataFieldType_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFormattedField >& _rxFormatted ); + }; + +//........................................................................ +} // namespace rptui +//........................................................................ + +#endif // REPORTDESIGN_FORMATNORMALIZER_HXX diff --git a/reportdesign/source/core/sdr/makefile.mk b/reportdesign/source/core/sdr/makefile.mk new file mode 100644 index 000000000000..5121b498b68d --- /dev/null +++ b/reportdesign/source/core/sdr/makefile.mk @@ -0,0 +1,52 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=reportdesign +TARGET=core_sdr +ENABLE_EXCEPTIONS=TRUE +# --- Settings ----------------------------------------------------- +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/dll.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= $(SLO)$/RptModel.obj \ + $(SLO)$/RptPage.obj \ + $(SLO)$/UndoActions.obj \ + $(SLO)$/RptObject.obj \ + $(SLO)$/RptObjectListener.obj \ + $(SLO)$/ModuleHelper.obj \ + $(SLO)$/PropertyForward.obj \ + $(SLO)$/ReportDrawPage.obj \ + $(SLO)$/ReportUndoFactory.obj \ + $(SLO)$/UndoEnv.obj \ + $(SLO)$/formatnormalizer.obj +# --- Targets ---------------------------------- + +.INCLUDE : target.mk |