diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-07-22 17:50:52 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-08-29 13:13:14 +0200 |
commit | 0bcc5b3daebeb2a7d2b5ba132af4745cc6c78cd0 (patch) | |
tree | 4fcff9413879a6dd789cee6e8450db5496785c75 /sw | |
parent | 5bed080c77f99f22fd52ad6cf2d6274e7c1e12a8 (diff) |
Switch isTextBox to use the format pointers
This replaces all possible occurences of the text box format
maps, which just want to know, if a SwFrameFormat is part of a
text box to use the direct lookup via the isTextBox, which is
now a cheap call.
Change-Id: I3b4e2301f816aead1b719cd70a8ef118e685ccfc
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/textboxhelper.hxx | 23 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/doc/docfly.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 56 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/frmedt/fecopy.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/objectpositioning/anchoredobjectposition.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 36 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/unocore/unoportenum.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfsdrexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltble.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 2 |
17 files changed, 96 insertions, 101 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index cce179607181..eb94bbc1d194 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -68,6 +68,19 @@ public: /// Return the textbox rectangle of a draw shape (in twips). static Rectangle getTextRectangle(SwFrameFormat* pShape, bool bAbsolute = true); + /** + * Is the frame format a text box? + * + * A text box consists of a coupled fly and draw format. Most times you + * just want to check for a single type, otherwise you get duplicate results. + * + * @param nType Expected frame format input type. + * Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT. + */ + static bool isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType); + /// Is pObject a textbox of a drawinglayer shape? + static bool isTextBox(const SdrObject* pObject); + /// Look up TextFrames in a document, which are in fact TextBoxes. static std::set<const SwFrameFormat*> findTextBoxes(const SwDoc* pDoc); /** @@ -77,16 +90,16 @@ public: * returned. */ static std::set<const SwFrameFormat*> findTextBoxes(const SwNode& rNode); - /// Is pObject a textbox of a drawinglayer shape? - static bool isTextBox(const SdrObject* pObject); /// Build a textbox -> shape format map. static std::map<SwFrameFormat*, SwFrameFormat*> findShapes(const SwDoc* pDoc); /// Count number of shapes in the document, excluding TextBoxes. - static sal_Int32 getCount(SdrPage* pPage, std::set<const SwFrameFormat*>& rTextBoxes); + static sal_Int32 getCount(const SwDoc* pDoc); + /// Count number of shapes on the page, excluding TextBoxes. + static sal_Int32 getCount(SdrPage* pPage); /// Get a shape by index, excluding TextBoxes. - static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<const SwFrameFormat*>& rTextBoxes) throw(css::lang::IndexOutOfBoundsException); + static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex) throw(css::lang::IndexOutOfBoundsException); /// Get the order of the shape, excluding TextBoxes. - static sal_Int32 getOrdNum(const SdrObject* pObject, std::set<const SwFrameFormat*>& rTextBoxes); + static sal_Int32 getOrdNum(const SdrObject* pObject); /// If pTextBox is a textbox, then set rWrapThrough to the surround of its shape. static void getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index e6f851cb5a2d..6e9341ed05fe 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -856,9 +856,8 @@ void SwUiWriterTest::testFdo82191() { SwDoc* pDoc = createDoc("fdo82191.odt"); SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); // Make sure we have a single draw shape. - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), SwTextBoxHelper::getCount(pPage, aTextBoxes)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), SwTextBoxHelper::getCount(pPage)); SwDoc aClipboard; SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); @@ -868,9 +867,8 @@ void SwUiWriterTest::testFdo82191() pWrtShell->Copy(&aClipboard); pWrtShell->Paste(&aClipboard); - aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); // This was one: the textbox of the shape wasn't copied. - CPPUNIT_ASSERT_EQUAL(size_t(2), aTextBoxes.size()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), SwTextBoxHelper::getCount(pDoc)); } void SwUiWriterTest::testCommentedWord() @@ -3446,15 +3444,20 @@ void SwUiWriterTest::testTdf92648() { SwDoc* pDoc = createDoc("tdf92648.docx"); SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); // Make sure we have ten draw shapes. - CPPUNIT_ASSERT_EQUAL(sal_Int32(10), SwTextBoxHelper::getCount(pPage, aTextBoxes)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(10), SwTextBoxHelper::getCount(pPage)); // and the text boxes haven't got zero height - for (std::set<const SwFrameFormat*>::iterator it=aTextBoxes.begin(); it!=aTextBoxes.end(); ++it) + sal_Int32 nCount = 0; + for (const SwFrameFormat* pFormat : *pDoc->GetSpzFrameFormats()) { - SwFormatFrameSize aSize((*it)->GetFrameSize()); + if (!SwTextBoxHelper::isTextBox(pFormat, RES_FLYFRMFMT)) + continue; + SwFormatFrameSize aSize(pFormat->GetFrameSize()); CPPUNIT_ASSERT(aSize.GetHeight() != 0); + ++nCount; } + // and we have had five of them. + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nCount); } void SwUiWriterTest::testTdf96515() diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index e1291b6673ba..98ffdae260f3 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -79,15 +79,11 @@ size_t SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const size_t nCount = 0; const SwNodeIndex* pIdx; - std::set<const SwFrameFormat*> aTextBoxes; - if (bIgnoreTextBoxes) - aTextBoxes = SwTextBoxHelper::findTextBoxes(this); - for ( size_t i = 0; i < nSize; ++i) { const SwFrameFormat* pFlyFormat = rFormats[ i ]; - if (bIgnoreTextBoxes && aTextBoxes.find(pFlyFormat) != aTextBoxes.end()) + if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) continue; if( RES_FLYFRMFMT == pFlyFormat->Which() @@ -131,15 +127,11 @@ SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreText const SwNodeIndex* pIdx; size_t nCount = 0; - std::set<const SwFrameFormat*> aTextBoxes; - if (bIgnoreTextBoxes) - aTextBoxes = SwTextBoxHelper::findTextBoxes(this); - for( size_t i = 0; !pRetFormat && i < nSize; ++i ) { SwFrameFormat* pFlyFormat = rFormats[ i ]; - if (bIgnoreTextBoxes && aTextBoxes.find(pFlyFormat) != aTextBoxes.end()) + if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) continue; if( RES_FLYFRMFMT == pFlyFormat->Which() @@ -177,10 +169,6 @@ std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats( SwFrameFormats& rFormats = *GetSpzFrameFormats(); const size_t nSize = rFormats.size(); - std::set<const SwFrameFormat*> aTextBoxes; - if (bIgnoreTextBoxes) - aTextBoxes = SwTextBoxHelper::findTextBoxes(this); - std::vector<SwFrameFormat const*> ret; ret.reserve(nSize); @@ -188,7 +176,7 @@ std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats( { SwFrameFormat const*const pFlyFormat = rFormats[ i ]; - if (bIgnoreTextBoxes && aTextBoxes.find(pFlyFormat) != aTextBoxes.end()) + if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) { continue; } diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index ce18cd058aeb..b1803661da25 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -160,6 +160,28 @@ std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc) return aTextBoxes; } +bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pShape, sal_uInt16 nType) +{ + assert(nType == RES_FLYFRMFMT || nType == RES_DRAWFRMFMT); + if (!pShape || pShape->Which() != nType || !pShape->GetAttrSet().HasItem(RES_CNTNT)) + return false; + + sal_uInt16 nOtherType = (pShape->Which() == RES_FLYFRMFMT) ? RES_DRAWFRMFMT : RES_FLYFRMFMT; + SwFrameFormat* pFormat = pShape->GetOtherTextBoxFormat(); + if (!pFormat) + return false; + + assert(pFormat->Which() == nOtherType); + if (pFormat->Which() != nOtherType) + return false; + + const SwFormatContent& rContent = pShape->GetContent(); + if (!pFormat->GetAttrSet().HasItem(RES_CNTNT) || pFormat->GetContent() != rContent) + return false; + + return true; +} + std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwNode& rNode) { const SwDoc* pDoc = rNode.GetDoc(); @@ -203,35 +225,39 @@ std::map<SwFrameFormat*, SwFrameFormat*> SwTextBoxHelper::findShapes(const SwDoc return aRet; } -/// If the passed SdrObject is in fact a TextFrame, that is used as a TextBox. -bool lcl_isTextBox(SdrObject* pSdrObject, std::set<const SwFrameFormat*>& rTextBoxes) -{ - SwVirtFlyDrawObj* pObject = dynamic_cast<SwVirtFlyDrawObj*>(pSdrObject); - return pObject && rTextBoxes.find(pObject->GetFormat()) != rTextBoxes.end(); -} - bool SwTextBoxHelper::isTextBox(const SdrObject* pObject) { const SwVirtFlyDrawObj* pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>(pObject); if (!pVirtFlyDrawObj) return false; - std::set<const SwFrameFormat*> aTextBoxes = findTextBoxes(pVirtFlyDrawObj->GetFormat()->GetDoc()); - return aTextBoxes.find(pVirtFlyDrawObj->GetFormat()) != aTextBoxes.end(); + return isTextBox(pVirtFlyDrawObj->GetFormat(), RES_FLYFRMFMT); } -sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage, std::set<const SwFrameFormat*>& rTextBoxes) +sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage) { sal_Int32 nRet = 0; for (std::size_t i = 0; i < pPage->GetObjCount(); ++i) { - if (lcl_isTextBox(pPage->GetObj(i), rTextBoxes)) + if (isTextBox(pPage->GetObj(i))) continue; ++nRet; } return nRet; } -uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<const SwFrameFormat*>& rTextBoxes) throw(lang::IndexOutOfBoundsException) +sal_Int32 SwTextBoxHelper::getCount(const SwDoc* pDoc) +{ + sal_Int32 nRet = 0; + const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); + for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != rSpzFrameFormats.end(); ++it) + { + if (isTextBox(*it, RES_FLYFRMFMT)) + ++nRet; + } + return nRet; +} + +uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex) throw(lang::IndexOutOfBoundsException) { if (nIndex < 0) throw lang::IndexOutOfBoundsException(); @@ -240,7 +266,7 @@ uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set< sal_Int32 nCount = 0; // Current logical index. for (std::size_t i = 0; i < pPage->GetObjCount(); ++i) { - if (lcl_isTextBox(pPage->GetObj(i), rTextBoxes)) + if (isTextBox(pPage->GetObj(i))) continue; if (nCount == nIndex) { @@ -256,14 +282,14 @@ uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set< return uno::makeAny(uno::Reference<drawing::XShape>(pRet->getUnoShape(), uno::UNO_QUERY)); } -sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject, std::set<const SwFrameFormat*>& rTextBoxes) +sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject) { if (const SdrPage* pPage = pObject->GetPage()) { sal_Int32 nOrder = 0; // Current logical order. for (std::size_t i = 0; i < pPage->GetObjCount(); ++i) { - if (lcl_isTextBox(pPage->GetObj(i), rTextBoxes)) + if (isTextBox(pPage->GetObj(i))) continue; if (pPage->GetObj(i) == pObject) return nOrder; diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 700194515dd1..6c60a8bb5d27 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1151,7 +1151,7 @@ class NestedUserCallHdl /// Notify the format's textbox that it should reconsider its position / size. void lcl_textBoxSizeNotify(SwFrameFormat* pFormat) { - if (SwTextBoxHelper::findTextBox(pFormat)) + if (SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT)) { // Just notify the textbox that the size has changed, the actual object size is not interesting. SfxItemSet aResizeSet(pFormat->GetDoc()->GetAttrPool(), RES_FRM_SIZE, RES_FRM_SIZE, 0); diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 277a0b6d011a..0c6547619bfb 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -902,7 +902,6 @@ bool SwFEShell::Paste( SwDoc* pClpDoc ) if( !Imp()->GetDrawView() ) MakeDrawView(); - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pClpDoc); for ( auto pCpyFormat : *pClpDoc->GetSpzFrameFormats() ) { bool bInsWithFormat = true; @@ -972,7 +971,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc ) } // Ignore TextBoxes, they are already handled in sw::DocumentLayoutManager::CopyLayoutFormat(). - if (aTextBoxes.find(pCpyFormat) != aTextBoxes.end()) + if (SwTextBoxHelper::isTextBox(pCpyFormat, RES_FLYFRMFMT)) continue; aAnchor.SetAnchor( pPos ); diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx index 1cf2c0fe026f..9488a4b103cb 100644 --- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx @@ -501,7 +501,7 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch pFrameFormat->SetFormatAttr(aSize); } nAdjustedRelPosY = nProposedRelPosY; - } else if ( SwTextBoxHelper::findTextBox(pFormat) ) + } else if ( SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT) ) // when the shape has a textbox, use only the proposed vertical position nAdjustedRelPosY = nProposedRelPosY; } diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 44e7b63bd6ac..79d3859d2a4b 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1088,13 +1088,11 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc) // #i104937# SwFrameFormat* pFormat( nullptr ); - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); - for( size_t i = 0; i < nSize; ++i ) { // #i104937# pFormat = (*pFormats)[i]; - if(pFormat->Which() != RES_FLYFRMFMT || aTextBoxes.find(pFormat) != aTextBoxes.end()) + if(pFormat->Which() != RES_FLYFRMFMT || SwTextBoxHelper::isTextBox(pFormat, RES_FLYFRMFMT)) continue; const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if(!pIdx || !pIdx->GetNodes().IsDocNodes()) diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index f3d7cf5614e2..846fe4252a70 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -397,10 +397,9 @@ SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage) SolarMutexGuard aGuard; std::insert_iterator<shapescontainer_t> pInserter = std::insert_iterator<shapescontainer_t>(m_aShapes, m_aShapes.begin()); sal_Int32 nCount = pDrawPage->getCount(); - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDrawPage->GetDoc()); for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++) { - uno::Reference<drawing::XShape> xShape(pDrawPage->getByIndex(nIdx, &aTextBoxes), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY); *pInserter++ = uno::makeAny(xShape); } } @@ -523,13 +522,7 @@ sal_Int32 SwXDrawPage::getCount() throw( uno::RuntimeException, std::exception ) else { GetSvxPage(); - - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); - - if (aTextBoxes.empty()) - return pDrawPage->getCount(); - else - return SwTextBoxHelper::getCount(pDrawPage->GetSdrPage(), aTextBoxes); + return SwTextBoxHelper::getCount(pDrawPage->GetSdrPage()); } } @@ -537,12 +530,6 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { - return getByIndex(nIndex, nullptr); -} - -uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex, std::set<const SwFrameFormat*>* pTextBoxes) - throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) -{ SolarMutexGuard aGuard; if(!pDoc) throw uno::RuntimeException(); @@ -550,17 +537,7 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex, std::set<const SwFrameFormat* throw lang::IndexOutOfBoundsException(); GetSvxPage(); - std::set<const SwFrameFormat*> aTextBoxes; - if (!pTextBoxes) - { - // We got no set, so let's generate one. - aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); - pTextBoxes = &aTextBoxes; - } - if (pTextBoxes->empty()) - return pDrawPage->getByIndex( nIndex ); - else - return SwTextBoxHelper::getByIndex(pDrawPage->GetSdrPage(), nIndex, *pTextBoxes); + return SwTextBoxHelper::getByIndex(pDrawPage->GetSdrPage(), nIndex); } uno::Type SwXDrawPage::getElementType() throw( uno::RuntimeException, std::exception ) @@ -1554,7 +1531,7 @@ uno::Any SwXShape::getPropertyValue(const OUString& rPropertyName) } else if (pEntry->nWID == FN_TEXT_BOX) { - bool bValue = SwTextBoxHelper::findTextBox(pFormat); + bool bValue = SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT); aRet <<= bValue; } else if (pEntry->nWID == RES_CHAIN) @@ -1759,8 +1736,7 @@ uno::Any SwXShape::getPropertyValue(const OUString& rPropertyName) bConvert = false; if (bConvert) { - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pFormat->GetDoc()); - aRet <<= SwTextBoxHelper::getOrdNum(pObj, aTextBoxes); + aRet <<= SwTextBoxHelper::getOrdNum(pObj); } } } @@ -1840,7 +1816,7 @@ uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates( else if (pEntry->nWID == FN_TEXT_BOX) { // The TextBox property is set, if we can find a textbox for this shape. - if (pFormat && SwTextBoxHelper::findTextBox(pFormat)) + if (pFormat && SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT)) pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; else pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index cca3207d6474..656d86851cfe 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1751,8 +1751,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& aValue >>= nZOrder; // Don't set an explicit ZOrder on TextBoxes. - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); - if( nZOrder >= 0 && aTextBoxes.find(pFormat) == aTextBoxes.end()) + if( nZOrder >= 0 && !SwTextBoxHelper::isTextBox(pFormat, RES_FLYFRMFMT) ) { SdrObject* pObject = GetOrCreateSdrObject( static_cast<SwFlyFrameFormat&>(*pFormat) ); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 8c43ba71bf94..ee4e4e995a12 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -165,19 +165,18 @@ struct FrameClientSortListLess namespace { - void lcl_CollectFrameAtNodeWithLayout(SwDoc* pDoc, const SwContentFrame* pCFrame, + void lcl_CollectFrameAtNodeWithLayout(const SwContentFrame* pCFrame, FrameClientSortList_t& rFrames, const sal_uInt16 nAnchorType) { auto pObjs = pCFrame->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()) + if(SwTextBoxHelper::isTextBox(&rFormat, RES_FLYFRMFMT)) continue; if(rFormat.GetAnchor().GetAnchorId() == nAnchorType) { @@ -211,7 +210,7 @@ void CollectFrameAtNode( const SwNodeIndex& rIdx, nullptr != (pCNd = rIdx.GetNode().GetContentNode()) && nullptr != (pCFrame = pCNd->getLayoutFrame( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())) ) { - lcl_CollectFrameAtNodeWithLayout(pDoc, pCFrame, rFrames, nChkType); + lcl_CollectFrameAtNodeWithLayout(pCFrame, rFrames, nChkType); } else { diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 07fe139b86f6..eac6691435be 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -716,8 +716,7 @@ lcl_ExportHints( const sal_Int32 nCurrentIndex, const bool bRightMoveForbidden, bool & o_rbCursorMoved, - sal_Int32 & o_rNextAttrPosition, - std::set<const SwFrameFormat*>& rTextBoxes) + sal_Int32 & o_rNextAttrPosition) { // if the attribute has a dummy character, then xRef is set (except META) // otherwise, the portion for the attribute is inserted into rPortions! @@ -887,7 +886,7 @@ lcl_ExportHints( break; // Robust #i81708 content in covered cells // Do not expose inline anchored textboxes. - if (rTextBoxes.find(pAttr->GetFlyCnt().GetFrameFormat()) != rTextBoxes.end()) + if (SwTextBoxHelper::isTextBox(pAttr->GetFlyCnt().GetFrameFormat(), RES_FLYFRMFMT)) break; pUnoCursor->Exchange(); @@ -1272,8 +1271,6 @@ static void lcl_CreatePortions( PortionStack_t PortionStack; PortionStack.push( PortionList_t(&i_rPortions, nullptr) ); - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pUnoCursor->GetNode()); - bool bAtEnd( false ); while (!bAtEnd) // every iteration consumes at least current character! { @@ -1324,7 +1321,7 @@ static void lcl_CreatePortions( // N.B.: side-effects nNextAttrIndex, bCursorMoved; may move cursor xRef = lcl_ExportHints(PortionStack, i_xParentText, pUnoCursor, pHints, i_nStartPos, i_nEndPos, nCurrentIndex, bAtEnd, - bCursorMoved, nNextAttrIndex, aTextBoxes); + bCursorMoved, nNextAttrIndex); if (PortionStack.empty()) { OSL_FAIL("CreatePortions: stack underflow"); diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index c4b105c5115d..163f45c145d9 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -146,7 +146,6 @@ struct DocxSdrExport::Impl rtl::Reference<sax_fastparser::FastAttributeList> m_pDashLineStyleAttr; bool m_bDMLAndVMLDrawingOpen; /// List of TextBoxes in this document: they are exported as part of their shape, never alone. - std::set<const SwFrameFormat*> m_aTextBoxes; /// Preserved rotation for TextFrames. sal_Int32 m_nDMLandVMLTextFrameRotation; @@ -166,7 +165,6 @@ struct DocxSdrExport::Impl m_pFlyWrapAttrList(nullptr), m_pBodyPrAttrList(nullptr), m_bDMLAndVMLDrawingOpen(false), - m_aTextBoxes(SwTextBoxHelper::findTextBoxes(m_rExport.m_pDoc)), m_nDMLandVMLTextFrameRotation(0) { } @@ -1783,7 +1781,7 @@ bool DocxSdrExport::Impl::checkFrameBtlr(SwNode* pStartNode, bool bDML) bool DocxSdrExport::isTextBox(const SwFrameFormat& rFrameFormat) { - return m_pImpl->m_aTextBoxes.find(&rFrameFormat) != m_pImpl->m_aTextBoxes.end(); + return SwTextBoxHelper::isTextBox(&rFrameFormat, RES_FLYFRMFMT); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 0786f7713339..d7a050666ade 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -640,7 +640,7 @@ void RtfSdrExport::AddSdrObject(const SdrObject& rObj) bool RtfSdrExport::isTextBox(const SwFrameFormat& rFrameFormat) { - return m_aTextBoxes.find(&rFrameFormat) != m_aTextBoxes.end(); + return SwTextBoxHelper::isTextBox(&rFrameFormat, RES_FLYFRMFMT); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 124debfa84b1..b238ed603f47 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -1102,8 +1102,7 @@ void SwXMLExport::ExportTable( const SwTableNode& rTableNd ) sal_uInt16 nPrefix = XML_NAMESPACE_TABLE; if (const SwFrameFormat* pFlyFormat = rTableNd.GetFlyFormat()) { - std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(rTableNd.GetDoc()); - if (aTextBoxes.find(pFlyFormat) != aTextBoxes.end()) + if (SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) nPrefix = XML_NAMESPACE_LO_EXT; } diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index 25cffb9c4589..a0b3b3504613 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -494,7 +494,7 @@ void SwDrawShell::GetState(SfxItemSet& rSet) { SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); // Allow creating a TextBox only in case this is a draw format without a TextBox so far. - if (pFrameFormat && pFrameFormat->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::findTextBox(pFrameFormat)) + if (pFrameFormat && pFrameFormat->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT)) { if (SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>( pObj) ) { @@ -517,7 +517,7 @@ void SwDrawShell::GetState(SfxItemSet& rSet) { SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); // Allow removing a TextBox only in case it has one. - if (pFrameFormat && SwTextBoxHelper::findTextBox(pFrameFormat)) + if (pFrameFormat && SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT)) bDisable = false; } diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 2c8a7416c7b1..44483341efad 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -441,7 +441,7 @@ static bool lcl_isTextBox(SdrObject* pObject) if (SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pObject->GetUserCall())) { if (SwFrameFormat* pFormat = pDrawContact->GetFormat()) - return SwTextBoxHelper::findTextBox(pFormat); + return SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT); } return false; } |