User: hr Date: 2007-08-02 14:32:25+0000 Modified: dba/reportdesign/source/core/sdr/RptObject.cxx
Log: INTEGRATION: CWS rpt23fix01 (1.3.2); FILE MERGED 2007/07/19 06:39:07 oj 1.3.2.7: #i78372# lock undo before setting position 2007/07/18 11:54:00 oj 1.3.2.6: #i78372# set props at section 2007/07/16 12:37:08 fs 1.3.2.5: #i79659# +ensureSdrObjectOwnership 2007/07/11 11:53:14 oj 1.3.2.4: #i78372# actulize section height when object was inserted 2007/07/11 11:22:40 oj 1.3.2.3: #i77157# impl center as well 2007/07/11 10:39:38 oj 1.3.2.2: #i78372# actulize section height when object was inserted 2007/07/11 09:58:17 oj 1.3.2.1: #i78520# allowd to add control with keyboard File Changes: Directory: /dba/reportdesign/source/core/sdr/ ============================================= File [changed]: RptObject.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/core/sdr/RptObject.cxx?r1=1.3&r2=1.4 Delta lines: +74 -36 --------------------- --- RptObject.cxx 2007-07-09 15:47:26+0000 1.3 +++ RptObject.cxx 2007-08-02 14:32:23+0000 1.4 @@ -211,12 +211,15 @@ ,nType); break; case OBJ_CUSTOMSHAPE: - pNewObj = new OCustomShape(_xComponent); + pNewObj = OCustomShape::Create( _xComponent ); break; default: OSL_ENSURE(0,"Unknown object id"); break; } + + ensureSdrObjectOwnership( _xComponent ); + return pNewObj; } // ----------------------------------------------------------------------------- @@ -502,16 +505,8 @@ } //---------------------------------------------------------------------------- -uno::Reference< uno::XInterface > OObjectBase::getUnoShapeOf( SdrObject& _rSdrObject ) +void OObjectBase::ensureSdrObjectOwnership( const uno::Reference< uno::XInterface >& _rxShape ) { - uno::Reference< uno::XInterface > xShape( _rSdrObject.getWeakUnoShape() ); - if ( xShape.is() ) - return xShape; - - xShape = _rSdrObject.SdrObject::getUnoShape(); - if ( !xShape.is() ) - return xShape; - // 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 @@ -519,12 +514,29 @@ // action. // Unfortunately, the SvxDrawPage implementation usually deletes SdrObjects // which are removed from it, which is deadly for us. To prevent this, - // we given the XShape implementation the ownership of the SdrObject, which + // we give the XShape implementation the ownership of the SdrObject, which // ensures the SvxDrawPage won't delete it. - SvxShape* pShape = SvxShape::getImplementation( xShape ); - OSL_ENSURE( pShape, "OObjectBase::getUnoShapeOf: can't access the SvxShape!" ); + 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; @@ -577,10 +589,23 @@ //---------------------------------------------------------------------------- void OCustomShape::NbcMove( const Size& rSize ) { - SdrObjCustomShape::NbcMove( rSize ); + if ( m_bIsListening ) + { + m_bIsListening = sal_False; + + if ( m_xReportComponent.is() ) + { + 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) @@ -609,6 +634,7 @@ if ( !m_xReportComponent.is() ) m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); } + SetPropsFromRect(GetSnapRect()); } return bResult; @@ -713,16 +739,28 @@ void OUnoObject::NbcMove( const Size& rSize ) { DBG_CHKTHIS( rpt_OUnoObject,NULL); - SdrUnoObj::NbcMove( rSize ); + 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 + SdrUnoObj::NbcMove( rSize ); } //---------------------------------------------------------------------------- @@ -740,7 +778,6 @@ // start listening OObjectBase::StartListening(); - } //---------------------------------------------------------------------------- void OUnoObject::NbcSetLogicRect(const Rectangle& rRect) @@ -771,31 +808,32 @@ m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); // set labels if ( m_xReportComponent.is() && supportsService( "com.sun.star.report.FixedText" ) ) - m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName()) ); + m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName(this)) ); } + // set geometry properties + SetPropsFromRect(GetLogicRect()); } return bResult; } //---------------------------------------------------------------------------- -::rtl::OUString OUnoObject::GetDefaultName() const +::rtl::OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj) { - DBG_CHKTHIS( rpt_OUnoObject,NULL); sal_uInt16 nResId = 0; ::rtl::OUString aDefaultName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HERE WE HAVE TO INSERT OUR NAME!")); - if ( supportsService( "com.sun.star.report.FixedText" ) ) + if ( _pObj->supportsService( "com.sun.star.report.FixedText" ) ) { nResId = RID_STR_CLASS_FIXEDTEXT; } - else if ( supportsService( "com.sun.star.report.FixedLine" ) ) + else if ( _pObj->supportsService( "com.sun.star.report.FixedLine" ) ) { nResId = RID_STR_CLASS_FIXEDLINE; } - else if ( supportsService( "com.sun.star.report.ImageControl" ) ) + else if ( _pObj->supportsService( "com.sun.star.report.ImageControl" ) ) { nResId = RID_STR_CLASS_IMAGECONTROL; } - else if ( supportsService( "com.sun.star.report.FormattedField" ) ) + else if ( _pObj->supportsService( "com.sun.star.report.FormattedField" ) ) { nResId = RID_STR_CLASS_FORMATTEDFIELD; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
