Kaydet (Commit) 4a070d46 authored tarafından Hans-Joachim Lankenau's avatar Hans-Joachim Lankenau

CWS-TOOLING: integrate CWS dba31k_DEV300

2009-03-17 11:26:36 +0100 oj  r269582 : #i100219# clean up refcount handling
üst 2a8efd9f
......@@ -365,6 +365,8 @@ namespace reportdesign
virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler() const;
virtual bool isEnableSetModified() const;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const;
private:
/** loads the report definition from the given storage
......
......@@ -98,6 +98,8 @@ public:
/// returns the XReportDefinition which the OReportModel belongs to
::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >
getReportDefinition() const;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createShape(const ::rtl::OUString& aServiceSpecifier,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rShape,sal_Int32 nOrientation = -1);
};
}
#endif
......
......@@ -110,9 +110,6 @@ void SAL_CALL OFixedText::dispose() throw(uno::RuntimeException)
FixedTextPropertySet::dispose();
cppu::WeakComponentImplHelperBase::dispose();
uno::Reference< report::XFixedText> xHoldAlive = this;
{
m_aProps.dispose(m_refCount);
}
}
// -----------------------------------------------------------------------------
::rtl::OUString OFixedText::getImplementationName_Static( ) throw(uno::RuntimeException)
......
......@@ -116,12 +116,8 @@ void SAL_CALL OFormattedField::dispose() throw(uno::RuntimeException)
{
FormattedFieldPropertySet::dispose();
cppu::WeakComponentImplHelperBase::dispose();
uno::Reference< report::XFormattedField> xHoldAlive = this;
{
m_xFormatsSupplier.clear();
m_xFunction.clear();
m_aProps.dispose(m_refCount);
}
m_xFormatsSupplier.clear();
m_xFunction.clear();
}
// -----------------------------------------------------------------------------
::rtl::OUString OFormattedField::getImplementationName_Static( ) throw(uno::RuntimeException)
......
......@@ -182,10 +182,6 @@ void SAL_CALL OImageControl::dispose() throw(uno::RuntimeException)
{
ImageControlPropertySet::dispose();
cppu::WeakComponentImplHelperBase::dispose();
uno::Reference< report::XImageControl> xHoldAlive = this;
{
m_aProps.dispose(m_refCount);
}
}
// -----------------------------------------------------------------------------
::rtl::OUString OImageControl::getImplementationName_Static( ) throw(uno::RuntimeException)
......
......@@ -41,7 +41,7 @@
#include "ReportControlModel.hxx"
#include <com/sun/star/reflection/XProxyFactory.hpp>
#include <com/sun/star/text/ParagraphVertAlign.hpp>
#include <svx/unoshape.hxx>
// #include <svx/unoshape.hxx>
#include <svx/unolingu.hxx>
#include <svtools/syslocale.hxx>
#include <svtools/lingucfg.hxx>
......@@ -122,10 +122,6 @@ void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xS
{
osl_incrementInterlockedCount( &_rRefCount );
{
// decrement the count from ReportDrawPage.cxx aArgs[0] <<= SvxDrawPage::_CreateShape( pObj );
SvxShape* pShape = SvxShape::getImplementation( _xShape );
if ( pShape )
pShape->release();
m_xProxy.set(_xShape,uno::UNO_QUERY);
::comphelper::query_aggregation(m_xProxy,m_xShape);
::comphelper::query_aggregation(m_xProxy,m_xProperty);
......@@ -138,21 +134,7 @@ void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xS
if ( m_xProxy.is() )
m_xProxy->setDelegator( _xTunnel );
}
// do not decrement the refcount again, this will be done from the any ReportDrawPage.cxx aArgs[0] <<= SvxDrawPage::_CreateShape( pObj ); , otherwise it will delete the object
//osl_decrementInterlockedCount( &_rRefCount );
}
// -----------------------------------------------------------------------------
void OReportComponentProperties::dispose(oslInterlockedCount& _rRefCount)
{
if ( m_xProxy.is() )
osl_decrementInterlockedCount( &_rRefCount );
//m_xShape.clear();
//m_xTypeProvider.clear();
//m_xUnoTunnel.clear();
//m_xServiceInfo.clear();
//m_xProperty.clear();
m_xContext.clear();
m_xFactory.clear();
osl_decrementInterlockedCount( &_rRefCount );
}
// -----------------------------------------------------------------------------
OReportComponentProperties::~OReportComponentProperties()
......
......@@ -152,13 +152,12 @@ void OReportControlModel::checkIndex(sal_Int32 _nIndex)
throw lang::IndexOutOfBoundsException();
}
// -----------------------------------------------------------------------------
void OReportControlModel::dispose(oslInterlockedCount& _rRefCount)
void OReportControlModel::dispose()
{
m_aFormatConditions.clear();
lang::EventObject aDisposeEvent( m_pOwner );
aContainerListeners.disposeAndClear( aDisposeEvent );
m_aFormatConditions.clear();
aComponent.dispose(_rRefCount);
}
// -----------------------------------------------------------------------------
bool OReportControlModel::isInterfaceForbidden(const uno::Type& _rType)
......
......@@ -705,7 +705,6 @@ void SAL_CALL OReportDefinition::dispose() throw(uno::RuntimeException)
{
ReportDefinitionPropertySet::dispose();
cppu::WeakComponentImplHelperBase::dispose();
m_aProps->dispose(m_refCount);
}
// -----------------------------------------------------------------------------
void SAL_CALL OReportDefinition::disposing()
......@@ -2069,68 +2068,19 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWith
::osl::MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
uno::Reference< drawing::XShape > xShape;
uno::Reference< embed::XStorage > xStorage;
sal_Int32 nOrientation = 1;
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 == PROPERTY_SHAPE )
xShape.set(aValue.Value,uno::UNO_QUERY);
else if ( aValue.Name == PROPERTY_ORIENTATION )
aValue.Value >>= nOrientation;
else if( aValue.Name.equalsAscii( "Storage" ) )
aValue.Value >>= xStorage;
}
uno::Reference< uno::XInterface > xRet;
if ( xShape.is() )
if ( aServiceSpecifier.indexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver"))) == 0 )
{
if ( aServiceSpecifier == SERVICE_FORMATTEDFIELD )
{
uno::Reference<report::XFormattedField> xProp = new OFormattedField(m_aProps->m_xContext,this,xShape);
xRet = xProp;
if ( xShape.is() )
throw uno::Exception();
xProp->setPropertyValue( PROPERTY_FORMATSSUPPLIER, uno::makeAny(uno::Reference< util::XNumberFormatsSupplier >(*this,uno::UNO_QUERY)) );
}
else if ( aServiceSpecifier == SERVICE_FIXEDTEXT)
{
xRet = static_cast<cppu::OWeakObject*>(new OFixedText(m_aProps->m_xContext,this,xShape));
if ( xShape.is() )
throw uno::Exception();
}
else if ( aServiceSpecifier == SERVICE_FIXEDLINE)
{
xRet = static_cast<cppu::OWeakObject*>(new OFixedLine(m_aProps->m_xContext,this,xShape,nOrientation));
if ( xShape.is() )
throw uno::Exception();
}
else if ( aServiceSpecifier == SERVICE_IMAGECONTROL )
{
xRet = static_cast<cppu::OWeakObject*>(new OImageControl(m_aProps->m_xContext,this,xShape));
if ( xShape.is() )
throw uno::Exception();
}
else if ( aServiceSpecifier == SERVICE_REPORTDEFINITION )
{
xRet = static_cast<cppu::OWeakObject*>(new OReportDefinition(m_aProps->m_xContext,this,xShape));
if ( xShape.is() )
throw uno::Exception();
}
else if ( xShape.is() )
uno::Reference< embed::XStorage > xStorage;
const uno::Any* pIter = _aArgs.getConstArray();
const uno::Any* pEnd = pIter + _aArgs.getLength();
for(;pIter != pEnd ;++pIter)
{
xRet = static_cast<cppu::OWeakObject*>(new OShape(m_aProps->m_xContext,this,xShape,aServiceSpecifier));
if ( xShape.is() )
throw uno::Exception();
}
}
else if ( aServiceSpecifier.indexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver"))) == 0 )
{
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 ));
}
......@@ -2256,19 +2206,7 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( co
else
xShape.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier ),uno::UNO_QUERY_THROW);
uno::Reference< uno::XInterface > xReturn;
{
uno::Sequence< uno::Any > aArgs(1);
{
beans::NamedValue aValue;
aValue.Name = PROPERTY_SHAPE;
aValue.Value <<= xShape; xShape.clear(); // keep exactly *one* reference!
aArgs[0] <<= aValue;
}
xReturn = createInstanceWithArguments(aServiceSpecifier,aArgs);
}
return xReturn;
return m_pImpl->m_pReportModel->createShape(aServiceSpecifier,xShape);
}
//-----------------------------------------------------------------------------
uno::Sequence< ::rtl::OUString > SAL_CALL OReportDefinition::getAvailableServiceNames(void) throw( uno::RuntimeException )
......@@ -2770,6 +2708,11 @@ uno::Reference< document::XDocumentProperties > SAL_CALL OReportDefinition::getD
}
return m_pImpl->m_xDocumentProperties;
}
// -----------------------------------------------------------------------------
uno::Reference< uno::XComponentContext > OReportDefinition::getContext() const
{
return m_aProps->m_xContext;
}
// =============================================================================
}// namespace reportdesign
// =============================================================================
......
......@@ -126,10 +126,6 @@ void SAL_CALL OShape::dispose() throw(uno::RuntimeException)
{
ShapePropertySet::dispose();
cppu::WeakComponentImplHelperBase::dispose();
uno::Reference< report::XShape> xHoldAlive = this;
{
m_aProps.dispose(m_refCount);
}
}
// -----------------------------------------------------------------------------
::rtl::OUString OShape::getImplementationName_Static( ) throw(uno::RuntimeException)
......
......@@ -85,8 +85,6 @@ namespace reportdesign
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);
void dispose(oslInterlockedCount& _rRefCount);
};
}
#endif // RPT_REPORTCOMPONENT_HXX
......
......@@ -115,7 +115,7 @@ namespace reportdesign
,bPrintWhenGroupChange(sal_False)
{}
void dispose(oslInterlockedCount& _rRefCount);
void dispose();
// XContainer
void addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
......
......@@ -30,6 +30,7 @@
#include "ReportDrawPage.hxx"
#include "RptObject.hxx"
#include "RptModel.hxx"
#include "RptDef.hxx"
#include "corestrings.hrc"
#include <comphelper/mimeconfighelper.hxx>
......@@ -143,20 +144,8 @@ uno::Reference< drawing::XShape > OReportDrawPage::_CreateShape( SdrObject *pOb
try
{
uno::Sequence< uno::Any > aArgs(bChangeOrientation ? 2 : 1);
{
beans::NamedValue aValue;
aValue.Name = PROPERTY_SHAPE;
aValue.Value <<= xShape; xShape.clear(); // keep exactly *one* reference!
aArgs[0] <<= aValue;
if ( bChangeOrientation )
{
aValue.Name = PROPERTY_ORIENTATION;
aValue.Value <<= sal_Int32(0);
aArgs[1] <<= aValue;
}
}
xRet.set( xFactory->createInstanceWithArguments( sServiceName, aArgs ), uno::UNO_QUERY_THROW );
OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel());
xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : -1), uno::UNO_QUERY_THROW );
}
catch( const uno::Exception& )
{
......
......@@ -48,10 +48,15 @@
#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);
......@@ -179,6 +184,53 @@ 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
//==================================================================
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment