sw/inc/textboxhelper.hxx | 33 ++- sw/qa/extras/uiwriter/uiwriter.cxx | 22 +- sw/source/core/doc/DocumentLayoutManager.cxx | 2 sw/source/core/doc/docfly.cxx | 18 - sw/source/core/doc/textboxhelper.cxx | 120 +++++++----- sw/source/core/draw/dcontact.cxx | 2 sw/source/core/draw/dview.cxx | 2 sw/source/core/frmedt/fecopy.cxx | 3 sw/source/core/frmedt/feshview.cxx | 8 sw/source/core/layout/fly.cxx | 5 sw/source/core/objectpositioning/anchoredobjectposition.cxx | 2 sw/source/core/text/porfly.cxx | 2 sw/source/core/unocore/unocoll.cxx | 4 sw/source/core/unocore/unodraw.cxx | 36 --- sw/source/core/unocore/unoframe.cxx | 3 sw/source/core/unocore/unoobj2.cxx | 7 sw/source/core/unocore/unoportenum.cxx | 9 sw/source/filter/ww8/docxattributeoutput.cxx | 4 sw/source/filter/ww8/docxsdrexport.cxx | 4 sw/source/filter/ww8/rtfsdrexport.cxx | 7 sw/source/filter/ww8/rtfsdrexport.hxx | 3 sw/source/filter/xml/xmltble.cxx | 3 sw/source/uibase/docvw/edtwin.cxx | 11 - sw/source/uibase/shells/drawsh.cxx | 4 sw/source/uibase/uiview/viewdraw.cxx | 2 25 files changed, 155 insertions(+), 161 deletions(-)
New commits: commit 69a870f01bfce9bf768069fd3912c1676e7a9c06 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Fri Jul 22 17:59:28 2016 +0200 Add convenience function getOtherTextBoxFormat Since we already have isTextBox to identify a text box, this just adds a call to SwFrameFormat::GetOtherTextBoxFormat() to actually return the corresponding SwFrameFormat. This gets rid off all the remaining occurences of the SwFrameFormat / Textbox sets and maps. (Manually cherry picked from commit f7f5d27066b696ac4e33246d3794bde8058e8622) Change-Id: Id5f05a1ff71e604658e7d8a0d0825f5671335b3f Reviewed-on: https://gerrit.libreoffice.org/46330 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index eb94bbc1d194..98983bad9f42 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -62,7 +62,17 @@ public: /// Similar to syncProperty(), but used by the internal API (e.g. for UI purposes). static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet& rSet); + /** + * If we have an associated TextFrame, then return that. + * + * @param nType Expected frame format type. + * Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT. + * + * @see isTextBox + */ + static SwFrameFormat* getOtherTextBoxFormat(const SwFrameFormat* pFormat, sal_uInt16 nType); /// If we have an associated TextFrame, then return that. + static SwFrameFormat* getOtherTextBoxFormat(css::uno::Reference<css::drawing::XShape> xShape); static SwFrameFormat* findTextBox(const SwFrameFormat* pShape); static SwFrameFormat* findTextBox(const css::uno::Reference<css::drawing::XShape>& xShape); /// Return the textbox rectangle of a draw shape (in twips). diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 5fc0d4cc7483..254a4ee14ba7 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -494,7 +494,7 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( pDest->MakeFrames(); // If the draw format has a TextBox, then copy its fly format as well. - if (SwFrameFormat* pSourceTextBox = SwTextBoxHelper::findTextBox(&rSource)) + if (SwFrameFormat* pSourceTextBox = SwTextBoxHelper::getOtherTextBoxFormat(&rSource, RES_DRAWFRMFMT)) { SwFormatAnchor boxAnchor(rNewAnchor); if (FLY_AS_CHAR == boxAnchor.GetAnchorId()) diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 33571730300e..12464e37e4b6 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -115,7 +115,7 @@ void SwTextBoxHelper::destroy(SwFrameFormat* pShape) // If a TextBox was enabled previously if (pShape->GetAttrSet().HasItem(RES_CNTNT)) { - SwFrameFormat* pFormat = findTextBox(pShape); + SwFrameFormat* pFormat = pShape->GetOtherTextBoxFormat(); // Unlink the TextBox's text range from the original shape. pShape->ResetFormatAttr(RES_CNTNT); @@ -129,7 +129,6 @@ void SwTextBoxHelper::destroy(SwFrameFormat* pShape) std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc) { std::set<const SwFrameFormat*> aTextBoxes; - std::map<SwNodeIndex, const SwFrameFormat*> aFlyFormats, aDrawFormats; const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != rSpzFrameFormats.end(); ++it) @@ -141,22 +140,8 @@ std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc) if (!pFormat->GetAttrSet().HasItem(RES_CNTNT) || !pFormat->GetContent().GetContentIdx()) continue; - const SwNodeIndex& rIndex = *pFormat->GetContent().GetContentIdx(); - - if (pFormat->Which() == RES_FLYFRMFMT) - { - if (aDrawFormats.find(rIndex) != aDrawFormats.end()) - aTextBoxes.insert(pFormat); - else - aFlyFormats[rIndex] = pFormat; - } - else if (pFormat->Which() == RES_DRAWFRMFMT) - { - if (aFlyFormats.find(rIndex) != aFlyFormats.end()) - aTextBoxes.insert(aFlyFormats[rIndex]); - else - aDrawFormats[rIndex] = pFormat; - } + if (pFormat->Which() == RES_FLYFRMFMT && nullptr != pFormat->GetOtherTextBoxFormat()) + aTextBoxes.insert(pFormat); } return aTextBoxes; @@ -199,7 +184,7 @@ std::set<const SwFrameFormat*> SwTextBoxHelper::findTextBoxes(const SwNode& rNod { for (SwAnchoredObject* pAnchoredObject : *pSortedObjs) { - SwFrameFormat* pTextBox = findTextBox(&pAnchoredObject->GetFrameFormat()); + SwFrameFormat* pTextBox = getOtherTextBoxFormat(&pAnchoredObject->GetFrameFormat(), RES_DRAWFRMFMT); if (pTextBox) aRet.insert(pTextBox); } @@ -219,7 +204,7 @@ std::map<SwFrameFormat*, SwFrameFormat*> SwTextBoxHelper::findShapes(const SwDoc const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != rSpzFrameFormats.end(); ++it) { - SwFrameFormat* pTextBox = findTextBox(*it); + SwFrameFormat* pTextBox = getOtherTextBoxFormat(*it, RES_DRAWFRMFMT); if (pTextBox) aRet[pTextBox] = *it; } @@ -305,11 +290,26 @@ sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject) void SwTextBoxHelper::getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough) { - std::map<SwFrameFormat*, SwFrameFormat*> aMap = findShapes(pTextBox->GetDoc()); - std::map<SwFrameFormat*, SwFrameFormat*>::iterator it = aMap.find(const_cast<SwFrameFormat*>(pTextBox)); - if (it != aMap.end()) - // pTextBox is indeed a TextBox, it->second is its shape. - rWrapThrough = it->second->GetSurround().GetSurround() == SURROUND_THROUGHT; + SwFrameFormat *pShape = SwTextBoxHelper::getOtherTextBoxFormat(pTextBox, RES_FLYFRMFMT); + if (pShape) + rWrapThrough = pShape->GetSurround().GetSurround() == SURROUND_THROUGHT; +} + +SwFrameFormat* SwTextBoxHelper::getOtherTextBoxFormat(const SwFrameFormat* pFormat, sal_uInt16 nType) +{ + if (!isTextBox(pFormat, nType)) + return nullptr; + return pFormat->GetOtherTextBoxFormat(); +} + +SwFrameFormat* SwTextBoxHelper::getOtherTextBoxFormat(uno::Reference<drawing::XShape> xShape) +{ + SwXShape* pShape = dynamic_cast<SwXShape*>(xShape.get()); + if (!pShape) + return nullptr; + + SwFrameFormat *pFormat = pShape->GetFrameFormat(); + return getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT); } SwFrameFormat* SwTextBoxHelper::findTextBox(const uno::Reference<drawing::XShape>& xShape) @@ -348,7 +348,7 @@ SwFrameFormat* SwTextBoxHelper::findTextBox(const SwFrameFormat* pShape) template < typename T > void lcl_queryInterface(SwFrameFormat* pShape, uno::Any& rAny) { - if (SwFrameFormat* pFormat = SwTextBoxHelper::findTextBox(pShape)) + if (SwFrameFormat* pFormat = SwTextBoxHelper::getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT)) { uno::Reference<T> const xInterface( SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat), @@ -426,7 +426,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, const OUString& rPrope syncProperty(pShape, RES_VERT_ORIENT, MID_VERTORIENT_POSITION, uno::makeAny(static_cast<sal_Int32>(convertTwipToMm100(aRectangle.Top())))); } - if (SwFrameFormat* pFormat = findTextBox(pShape)) + if (SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT)) { comphelper::SequenceAsHashMap aCustomShapeGeometry(rValue); // That would be the btLr text direction which we don't support at a frame level, so do it at a character level. @@ -460,7 +460,7 @@ void SwTextBoxHelper::getProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uI nMemberId &= ~CONVERT_TWIPS; - if (SwFrameFormat* pFormat = findTextBox(pShape)) + if (SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT)) { if (nWID == RES_CHAIN) { @@ -490,7 +490,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u uno::Any aValue(rValue); nMemberId &= ~CONVERT_TWIPS; - if (SwFrameFormat* pFormat = findTextBox(pShape)) + if (SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT)) { OUString aPropertyName; bool bAdjustX = false; @@ -631,9 +631,7 @@ void SwTextBoxHelper::saveLinks(const SwFrameFormats& rFormats, std::map<const S for (std::size_t i = 0; i < rFormats.size(); ++i) { const SwFrameFormat* pFormat = rFormats[i]; - if (pFormat->Which() != RES_DRAWFRMFMT) - continue; - if (SwFrameFormat* pTextBox = findTextBox(pFormat)) + if (SwFrameFormat* pTextBox = getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT)) rLinks[pFormat] = pTextBox; } } @@ -670,7 +668,7 @@ void SwTextBoxHelper::restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrame void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet& rSet) { - if (SwFrameFormat* pFormat = findTextBox(&rShape)) + if (SwFrameFormat* pFormat = getOtherTextBoxFormat(&rShape, RES_DRAWFRMFMT)) { SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange); diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 2bd03bfce93c..1d036aa7d125 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -966,7 +966,7 @@ void SwDrawView::DeleteMarked() SdrObject *pObject = rMarkList.GetMark(i)->GetMarkedSdrObj(); SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall(pObject)); SwFrameFormat* pFormat = pDrawContact->GetFormat(); - if (SwFrameFormat* pTextBox = SwTextBoxHelper::findTextBox(pFormat)) + if (SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT)) aTextBoxesToDelete.push_back(pTextBox); } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index e41ee3965cde..2c8553b64efc 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -232,15 +232,13 @@ bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj ) if (!(nFlag & SW_ALLOW_TEXTBOX)) { // If the fly frame is a textbox of a shape, then select the shape instead. - std::map<SwFrameFormat*, SwFrameFormat*> aTextBoxShapes = SwTextBoxHelper::findShapes(mpDoc); for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i) { SdrObject* pObject = rMrkList.GetMark(i)->GetMarkedSdrObj(); - SwContact* pDrawContact = static_cast<SwContact*>(GetUserCall(pObject)); - SwFrameFormat* pFormat = pDrawContact->GetFormat(); - if (aTextBoxShapes.find(pFormat) != aTextBoxShapes.end()) + SwFrameFormat* pFormat = GetUserCall(pObject)->GetFormat(); + if (SwFrameFormat* pShapeFormat = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_FLYFRMFMT)) { - SdrObject* pShape = aTextBoxShapes[pFormat]->FindSdrObject(); + SdrObject* pShape = pShapeFormat->FindSdrObject(); pDView->UnmarkAll(); pDView->MarkObj(pShape, Imp()->GetPageView(), bAddSelect, bEnterGroup); break; diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 66c131d80f6d..fa98ceaf5c4c 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -1294,11 +1294,10 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA } mbValidSize = true; - std::map<SwFrameFormat*, SwFrameFormat*> aShapes = SwTextBoxHelper::findShapes(GetFormat()->GetDoc()); - if (aShapes.find(GetFormat()) != aShapes.end()) + if (SwFrameFormat* pShapeFormat = SwTextBoxHelper::getOtherTextBoxFormat(GetFormat(), RES_FLYFRMFMT)) { // This fly is a textbox of a draw shape. - SdrObject* pShape = aShapes[GetFormat()]->FindSdrObject(); + SdrObject* pShape = pShapeFormat->FindSdrObject(); if (SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>( pShape) ) { // The shape is a customshape: then inform it about the calculated fly size. diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 43ab530992ae..a0b91031522d 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -359,7 +359,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase, if (rAnchor.GetAnchorId() == FLY_AS_CHAR) { // This is an inline draw shape, see if it has a textbox. - SwFrameFormat* pTextBox = SwTextBoxHelper::findTextBox(pShape); + SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT); if (pTextBox) { // It has, so look up its text rectangle, and adjust the position diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f05afd2652ab..fcd5bcf5f498 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5428,7 +5428,7 @@ void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape) DocxTableExportContext aTableExportContext; pushToTableExportContext(aTableExportContext); - SwFrameFormat* pTextBox = SwTextBoxHelper::findTextBox(xShape); + SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape); const SwPosition* pAnchor = pTextBox->GetAnchor().GetContentAnchor(); ww8::Frame aFrame(*pTextBox, *pAnchor); m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true); @@ -5441,7 +5441,7 @@ void DocxAttributeOutput::WriteVMLTextBox(uno::Reference<drawing::XShape> xShape DocxTableExportContext aTableExportContext; pushToTableExportContext(aTableExportContext); - SwFrameFormat* pTextBox = SwTextBoxHelper::findTextBox(xShape); + SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape); const SwPosition* pAnchor = pTextBox->GetAnchor().GetContentAnchor(); ww8::Frame aFrame(*pTextBox, *pAnchor); m_rExport.SdrExporter().writeVMLTextFrame(&aFrame, /*bTextBoxOnly=*/true); diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index f303e8a379a6..48da64f56d56 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -39,8 +39,7 @@ RtfSdrExport::RtfSdrExport(RtfExport& rExport) m_nShapeType(ESCHER_ShpInst_Nil), m_nShapeFlags(0) , m_aShapeStyle(200), - m_pShapeTypeWritten(new bool[ ESCHER_ShpInst_COUNT ]), - m_aTextBoxes(SwTextBoxHelper::findTextBoxes(m_rExport.m_pDoc)) + m_pShapeTypeWritten(new bool[ ESCHER_ShpInst_COUNT ]) { mnGroupLevel = 1; memset(m_pShapeTypeWritten, 0, ESCHER_ShpInst_COUNT * sizeof(bool)); @@ -514,7 +513,7 @@ sal_Int32 RtfSdrExport::StartShape() const SwFrameFormat* pShape = FindFrameFormat(m_pSdrObject); if (pShape) { - if (SwFrameFormat* pTextBox = SwTextBoxHelper::findTextBox(pShape)) + if (SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT)) { ww8::Frame* pFrame = nullptr; for (ww8::FrameIter it = m_rExport.m_aFrames.begin(); it != m_rExport.m_aFrames.end(); ++it) diff --git a/sw/source/filter/ww8/rtfsdrexport.hxx b/sw/source/filter/ww8/rtfsdrexport.hxx index 15a7fbf7e705..eef0b5047a54 100644 --- a/sw/source/filter/ww8/rtfsdrexport.hxx +++ b/sw/source/filter/ww8/rtfsdrexport.hxx @@ -56,9 +56,6 @@ class RtfSdrExport : public EscherEx /// Remember which shape types we had already written. bool* m_pShapeTypeWritten; - /// List of TextBoxes in this document: they are exported as part of their shape, never alone. - std::set<const SwFrameFormat*> m_aTextBoxes; - public: explicit RtfSdrExport(RtfExport& rExport); virtual ~RtfSdrExport(); diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 2ded67656383..b8b8b588c296 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -204,7 +204,7 @@ static bool lcl_goIntoTextBox(SwEditWin& rEditWin, SwWrtShell& rSh) { SdrObject* pSdrObject = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); SwFrameFormat* pObjectFormat = ::FindFrameFormat(pSdrObject); - if (SwFrameFormat* pTextBoxFormat = SwTextBoxHelper::findTextBox(pObjectFormat)) + if (SwFrameFormat* pTextBoxFormat = SwTextBoxHelper::getOtherTextBoxFormat(pObjectFormat, RES_DRAWFRMFMT)) { SdrObject* pTextBox = pTextBoxFormat->FindRealSdrObject(); SdrView* pSdrView = rSh.GetDrawView(); @@ -4402,10 +4402,9 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) SdrPageView* pPV; if (pSdrView && pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SdrSearchOptions::ALSOONMASTER )) { - std::map<SwFrameFormat*, SwFrameFormat*> aTextBoxShapes = SwTextBoxHelper::findShapes(rSh.GetDoc()); - auto pDrawContact = GetUserCall(pObj); - SwFrameFormat* pFormat = pDrawContact->GetFormat(); - if (aTextBoxShapes.find(pFormat) == aTextBoxShapes.end()) + SwFrameFormat* pFormat = GetUserCall(pObj)->GetFormat(); + SwFrameFormat* pShapeFormat = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_FLYFRMFMT); + if (!pShapeFormat) { pSdrView->UnmarkAllObj(); pSdrView->MarkObj(pObj,pPV); @@ -4413,7 +4412,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) else { // If the fly frame is a textbox of a shape, then select the shape instead. - SdrObject* pShape = aTextBoxShapes[pFormat]->FindSdrObject(); + SdrObject* pShape = pShapeFormat->FindSdrObject(); pSdrView->UnmarkAllObj(); pSdrView->MarkObj(pShape, pPV); } commit c62e2df5f634654008efd449a502bb57352ebb43 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Fri Jul 22 17:50:52 2016 +0200 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. (Manually cherry picked from commit 0bcc5b3daebeb2a7d2b5ba132af4745cc6c78cd0) Change-Id: I3b4e2301f816aead1b719cd70a8ef118e685ccfc Reviewed-on: https://gerrit.libreoffice.org/46306 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> 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 119ff204d179..766ab7199419 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -858,9 +858,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(); @@ -870,9 +869,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() @@ -3389,15 +3387,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() @@ -3721,8 +3724,7 @@ void SwUiWriterTest::testTdf78727() SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); // This was 1: make sure we don't loose the TextBox anchored inside the // table that is moved inside a text frame. - std::set<const SwFrameFormat*> aSet; - CPPUNIT_ASSERT(SwTextBoxHelper::getCount(pPage, aSet) > 1); + CPPUNIT_ASSERT(SwTextBoxHelper::getCount(pPage) > 1); } // accepting change tracking gets stuck on change 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 c75908384ebf..33571730300e 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -162,6 +162,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(); @@ -205,35 +227,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(); @@ -242,7 +268,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) { @@ -258,14 +284,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 b9ef741b2d35..080af8dc9386 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 5506cb9b8e58..a33f4bb906bf 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 d369ac46132a..2f387808b11e 100644 --- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx @@ -505,7 +505,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 09ee314ace34..c37608ddb3ab 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1080,13 +1080,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 47ebb0b719e5..8ecd6d4ba2a0 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -400,10 +400,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); } } @@ -526,13 +525,7 @@ sal_Int32 SwXDrawPage::getCount() throw( uno::RuntimeException, std::exception ) else { static_cast<SwXDrawPage*>(this)->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()); } } @@ -540,12 +533,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(); @@ -553,17 +540,7 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex, std::set<const SwFrameFormat* throw lang::IndexOutOfBoundsException(); static_cast<SwXDrawPage*>(this)->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 ) @@ -1564,7 +1541,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) @@ -1770,8 +1747,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); } } } @@ -1852,7 +1828,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 2bb4a87ce860..15abdb2193bf 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1750,8 +1750,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 71619b352d6b..9ae7b3cca044 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 920f3b70b8f6..c45d88a6908c 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 a5b2c38b72a6..01a546650e1d 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -145,7 +145,6 @@ struct DocxSdrExport::Impl css::uno::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; @@ -165,7 +164,6 @@ struct DocxSdrExport::Impl m_pFlyWrapAttrList(nullptr), m_pBodyPrAttrList(nullptr), m_bDMLAndVMLDrawingOpen(false), - m_aTextBoxes(SwTextBoxHelper::findTextBoxes(m_rExport.m_pDoc)), m_nDMLandVMLTextFrameRotation(0) { } @@ -1798,7 +1796,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 77d4645db57e..f303e8a379a6 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 d1bb91069812..172c4e588c02 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -1097,8 +1097,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 6c1fc4360ab9..332497da5c35 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 2ab98fea04b9..fda4a3b2d244 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -438,7 +438,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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits