diff --git a/sw/source/core/inc/sortedobjs.hxx b/sw/source/core/inc/sortedobjs.hxx index a57ed1570f82..2ebdbae2f340 100644 --- a/sw/source/core/inc/sortedobjs.hxx +++ b/sw/source/core/inc/sortedobjs.hxx @@ -51,6 +51,7 @@ class SwSortedObjs std::vector< SwAnchoredObject* > maSortedObjLst; public: + typedef std::vector::const_iterator const_iterator; SwSortedObjs(); ~SwSortedObjs(); @@ -62,6 +63,10 @@ class SwSortedObjs input parameter - index of entry, valid value range [0..size()-1] */ SwAnchoredObject* operator[]( size_t _nIndex ) const; + const_iterator begin() const + { return maSortedObjLst.cbegin(); }; + const_iterator end() const + { return maSortedObjLst.cend(); }; bool Insert( SwAnchoredObject& _rAnchoredObj ); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 5a6f56e29019..ea4852752457 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -165,6 +165,35 @@ struct FrameClientSortListLess } }; +namespace +{ + void lcl_CollectFrameAtNodeWithLayout(SwDoc* pDoc, const SwContentFrm* pCFrm, + FrameClientSortList_t& rFrames, + const sal_uInt16 nAnchorType) + { + auto pObjs = pCFrm->GetDrawObjs(); + if(!pObjs) + return; + const auto aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); + for(const auto pAnchoredObj : *pObjs) + { + SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat(); + // Filter out textboxes, which are not interesting at an UNO level. + if(aTextBoxes.find(&rFormat) != aTextBoxes.end()) + continue; + if(rFormat.GetAnchor().GetAnchorId() == nAnchorType) + { + const auto nIdx = + rFormat.GetAnchor().GetContentAnchor()->nContent.GetIndex(); + const auto nOrder = rFormat.GetAnchor().GetOrder(); + FrameClientSortListEntry entry(nIdx, nOrder, new sw::FrameClient(&rFormat)); + rFrames.push_back(entry); + } + } + } +} + + void CollectFrameAtNode( const SwNodeIndex& rIdx, FrameClientSortList_t& rFrames, const bool bAtCharAnchoredObjs ) @@ -176,7 +205,7 @@ void CollectFrameAtNode( const SwNodeIndex& rIdx, // search all borders, images, and OLEs that are connected to the paragraph SwDoc* pDoc = rIdx.GetNode().GetDoc(); - const sal_uInt16 nChkType = static_cast< sal_uInt16 >((bAtCharAnchoredObjs) + const auto nChkType = static_cast< sal_uInt16 >((bAtCharAnchoredObjs) ? FLY_AT_CHAR : FLY_AT_PARA); const SwContentFrm* pCFrm; const SwContentNode* pCNd; @@ -184,34 +213,7 @@ void CollectFrameAtNode( const SwNodeIndex& rIdx, 0 != (pCNd = rIdx.GetNode().GetContentNode()) && 0 != (pCFrm = pCNd->getLayoutFrm( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())) ) { - const SwSortedObjs *pObjs = pCFrm->GetDrawObjs(); - if( pObjs ) - { - std::set aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); - for( size_t i = 0; i < pObjs->size(); ++i ) - { - SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; - SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat(); - - // Filter out textboxes, which are not interesting at an UNO level. - if (aTextBoxes.find(&rFormat) != aTextBoxes.end()) - continue; - - if ( rFormat.GetAnchor().GetAnchorId() == nChkType ) - { - // create SwDepend and insert into array - sw::FrameClient* pNewClient = new sw::FrameClient( &rFormat ); - const sal_Int32 idx = - rFormat.GetAnchor().GetContentAnchor()->nContent.GetIndex(); - sal_uInt32 nOrder = rFormat.GetAnchor().GetOrder(); - - // OD 2004-05-07 #i28701# - sorting no longer needed, - // because list is already sorted. - FrameClientSortListEntry entry(idx, nOrder, pNewClient); - rFrames.push_back(entry); - } - } - } + lcl_CollectFrameAtNodeWithLayout(pDoc, pCFrm, rFrames, nChkType); } else {