diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-20 13:49:44 +0200 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2023-04-26 14:01:20 +0200 |
commit | 397c30d9faae596803ebb087fb609d8eb52e1efd (patch) | |
tree | 97a6bd582b0cbdcaa20c66320686cb8ed422162e | |
parent | tdf#154946: Draw/Impress Standard toolbar missing many icons (diff) | |
download | core-397c30d9faae596803ebb087fb609d8eb52e1efd.tar.gz core-397c30d9faae596803ebb087fb609d8eb52e1efd.zip |
tdf#154827 and tdf#154428 graphics anchored in Writer as character..
..become anchored at paragraph when reopening the document
regression from
commit 8611f6e259b807b4f19c8dc0eab86ca648891ce3
ref-count SdrObject
This used to work by accident, previously, the SwXGroupShape that we
need would get created and destroyed and handful of times, and then
properly created.
Now, however, the first time we create it it sticks around, which means
it does not get the m_pFormat field configured correctly.
Fix this by removing the caching of m_pFormat from SwXShape, and just
fetching it from the model when we need it.
Change-Id: I10fe2ad0b877b3d928d5288e73cfed373b27a506
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150687
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 40babcfa637957bf7b59caa3cd12a630189e3e63)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150719
(cherry picked from commit e1beab2488a417e5fc3d63265d8e71c3807755f8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150725
Reviewed-by: Stéphane Guillou <stephane.guillou@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | sw/inc/unodraw.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 28 |
2 files changed, 10 insertions, 27 deletions
diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx index d7a768317bbf..36922cc086f1 100644 --- a/sw/inc/unodraw.hxx +++ b/sw/inc/unodraw.hxx @@ -121,7 +121,6 @@ class SwXShape : public SwXShapeBaseClass, public SvtListener friend class SwXGroupShape; friend class SwFmDrawPage; const SwFmDrawPage* m_pPage; - SwFrameFormat* m_pFormat; css::uno::Reference< css::uno::XAggregation > m_xShapeAgg; // reference to <XShape>, determined in the @@ -184,12 +183,6 @@ class SwXShape : public SwXShapeBaseClass, public SvtListener @throws css::uno::RuntimeException */ css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName ); - void SetFrameFormat(SwFrameFormat* pFormat) - { - EndListeningAll(); - StartListening(pFormat->GetNotifier()); - m_pFormat = pFormat; - } protected: virtual ~SwXShape() override; @@ -241,7 +234,7 @@ public: virtual OUString SAL_CALL getShapeType( ) override; SwShapeDescriptor_Impl* GetDescImpl() {return m_pImpl.get();} - SwFrameFormat* GetFrameFormat() const { return m_pFormat; } + SwFrameFormat* GetFrameFormat() const; const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() const {return m_xShapeAgg;} // helper diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 517dd5aaa8cd..a501d1b7673f 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -538,7 +538,7 @@ void SwFmDrawPage::add(const uno::Reference< drawing::XShape > & xShape) static_cast< cppu::OWeakObject * > ( this ) ); // we're already registered in the model / SwXDrawPage::add() already called - if(pShape->m_pPage || pShape->m_pFormat || !pShape->m_bDescriptor ) + if(pShape->m_pPage || !pShape->m_bDescriptor ) return; // we're inserted elsewhere already @@ -686,7 +686,6 @@ void SwFmDrawPage::add(const uno::Reference< drawing::XShape > & xShape) { pFormat->SetFormatName(pSvxShape->GetSdrObject()->GetName(), false); } - pShape->SetFrameFormat(pFormat); } pShape->m_bDescriptor = false; @@ -816,7 +815,6 @@ SwXShape::SwXShape( uno::Reference<uno::XInterface> & xShape, SwDoc const*const pDoc) : m_pPage(nullptr) - , m_pFormat(nullptr) , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)) , m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)) , m_pImpl(new SwShapeDescriptor_Impl(pDoc)) @@ -847,16 +845,20 @@ SwXShape::SwXShape( SdrObject* pObj = SdrObject::getSdrObjectFromXShape(m_xShapeAgg); if(pObj) { - auto pFormat = ::FindFrameFormat( pObj ); - if(pFormat) - SetFrameFormat(pFormat); - lcl_addShapePropertyEventFactories( *pObj, *this ); m_pImpl->m_bInitializedPropertyNotifier = true; } } +SwFrameFormat* SwXShape::GetFrameFormat() const +{ + SdrObject* pObj = SdrObject::getSdrObjectFromXShape(m_xShapeAgg); + if(pObj) + return ::FindFrameFormat( pObj ); + return nullptr; +} + void SwXShape::AddExistingShapeToFormat( SdrObject const & _rObj ) { SdrObjListIter aIter( _rObj, SdrIterMode::DeepNoGroups ); @@ -871,12 +873,7 @@ void SwXShape::AddExistingShapeToFormat( SdrObject const & _rObj ) if ( pSwShape ) { if ( pSwShape->m_bDescriptor ) - { - auto pFormat = ::FindFrameFormat( pCurrent ); - if ( pFormat ) - pSwShape->SetFrameFormat(pFormat); pSwShape->m_bDescriptor = false; - } if ( !pSwShape->m_pImpl->m_bInitializedPropertyNotifier ) { @@ -1990,7 +1987,6 @@ void SwXShape::Notify(const SfxHint& rHint) { if(rHint.GetId() == SfxHintId::Dying) { - m_pFormat = nullptr; EndListeningAll(); } } @@ -2739,12 +2735,6 @@ void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) } } pSwShape->m_bDescriptor = false; - //add the group member to the format of the group - SwFrameFormat* pShapeFormat = ::FindFrameFormat( pSvxShape->GetSdrObject() ); - - if(pShapeFormat) - pSwShape->SetFrameFormat(pShapeFormat); - } void SwXGroupShape::remove( const uno::Reference< XShape >& xShape ) |