diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2023-04-27 22:57:09 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2023-04-28 14:53:45 +0200 |
commit | 6fab79859ec97a9153e033fe00fd01e4e46620ce (patch) | |
tree | ff7f612626febfa8b26767ce0bd36411e4e35d11 /sw | |
parent | 10f289477971fe27a5062f02fbb07a44c79e2778 (diff) |
Revert "Revert "introduce sw::SpzFrameFormat ...""
apparently, in SwHistoryChangeFlyAnchor::SetInDoc, m_rFormat might
actually reference a DrawFormat, not a FlyFormat, and that is likely
fundamentally broken. But for now, lets just make m_rFormat a
sw::SpzFrameFormat -- this already removes some pointless up and
downcasting.
This reverts commit 52acefd6024ec79f8333ba40eef83816eda3046f.
Change-Id: I040d98548bf9ac1c25b93214224eb0812f8cb653
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151150
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
66 files changed, 290 insertions, 324 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index abd55424f359..ef630faf1a33 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -248,7 +248,7 @@ class SW_DLLPUBLIC SwDoc final std::unique_ptr<SwFrameFormats> mpFrameFormatTable; //< Format table std::unique_ptr<SwCharFormats> mpCharFormatTable; - std::unique_ptr<SwFrameFormats> mpSpzFrameFormatTable; + std::unique_ptr<sw::FrameFormats<sw::SpzFrameFormat*>> mpSpzFrameFormatTable; std::unique_ptr<SwSectionFormats> mpSectionFormatTable; std::unique_ptr<sw::TableFrameFormats> mpTableFrameFormatTable; //< For tables std::unique_ptr<SwTextFormatColls> mpTextFormatCollTable; //< FormatCollections @@ -754,8 +754,8 @@ public: SwCharFormats* GetCharFormats() { return mpCharFormatTable.get();} // LayoutFormats (frames, DrawObjects), sometimes const sometimes not - const SwFrameFormats* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); } - SwFrameFormats* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); } + const sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); } + sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); } const SwFrameFormat *GetDfltFrameFormat() const { return mpDfltFrameFormat.get(); } SwFrameFormat *GetDfltFrameFormat() { return mpDfltFrameFormat.get(); } diff --git a/sw/inc/frameformats.hxx b/sw/inc/frameformats.hxx index 97c86408e867..be3e5fd9ae77 100644 --- a/sw/inc/frameformats.hxx +++ b/sw/inc/frameformats.hxx @@ -19,6 +19,7 @@ #pragma once #include "docary.hxx" +#include "frmfmt.hxx" #include "swtblfmt.hxx" #include <boost/multi_index_container.hpp> #include <boost/multi_index/composite_key.hpp> @@ -153,6 +154,10 @@ template <class value_type> class FrameFormats final : public SwFormatsBase friend class ::SwFrameFormat; public: + // getting from T* to T const* ... + typedef typename std::add_pointer< + typename std::add_const<typename std::remove_pointer<value_type>::type>::type>::type + const_value_type; typedef typename FrameFormatsContainer::size_type size_type; typedef typename FrameFormatsContainer::template index<ByPos>::type index_type; typedef typename index_type::iterator iterator; @@ -274,7 +279,12 @@ public: bool ContainsFormat(const value_type& rpFormat) const { return rpFormat->m_ffList == this; }; /// not so fast check that given format is still alive (i.e. contained here) - bool IsAlive(value_type const* p) const { return find(*p) != end(); }; + bool IsAlive(const_value_type pFrameFormat) const + { + auto pThisNonConst + = const_cast<typename std::remove_const<sw::FrameFormats<value_type>>::type*>(this); + return pThisNonConst->find(const_cast<value_type>(pFrameFormat)) != pThisNonConst->end(); + }; void DeleteAndDestroyAll(bool keepDefault = false) { @@ -314,8 +324,10 @@ public: }; }; typedef FrameFormats<::SwTableFormat*> TableFrameFormats; +typedef FrameFormats<sw::SpzFrameFormat*> SpzFrameFormats; } template class SW_DLLPUBLIC sw::FrameFormats<SwTableFormat*>; +template class SW_DLLPUBLIC sw::FrameFormats<sw::SpzFrameFormat*>; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index f5e44e03136c..309aa78de552 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -23,20 +23,27 @@ #include <com/sun/star/text/PositionLayoutDir.hpp> #include <cppuhelper/weakref.hxx> #include <tools/gen.hxx> +namespace sw +{ + template<class T> class FrameFormats; + class SpzFrameFormat; +} #include "format.hxx" #include "hintids.hxx" #include "swdllapi.h" #include <list> #include "textboxhelper.hxx" -class SwFlyFrame; -class SwFlyDrawContact; -class SwAnchoredObject; class Graphic; -class ImageMap; class IMapObject; -class SwRect; +class ImageMap; class SdrObject; +class SwAnchoredObject; +class SwDrawFrameFormat; +class SwFlyDrawContact; +class SwFlyFrame; +class SwFlyFrameFormat; +class SwRect; class SwRootFrame; class SwTableBox; @@ -54,6 +61,7 @@ namespace sw virtual ~FindSdrObjectHint() override; }; template<class T> class FrameFormats; + class SpzFrameFormat; } class SwFormatsBase; class SwFrameFormats; @@ -68,6 +76,7 @@ class SW_DLLPUBLIC SwFrameFormat friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor. friend class SwFrameFormats; ///< Is allowed to update the list backref. friend class sw::FrameFormats<SwTableFormat*>; ///< Is allowed to update the list backref. + friend class sw::FrameFormats<sw::SpzFrameFormat*>; ///< Is allowed to update the list backref. friend class SwTextBoxHelper; friend class SwUndoFlyBase; ///< calls SetOtherTextBoxFormat @@ -190,9 +199,25 @@ public: virtual bool IsVisible() const; }; +namespace sw +{ + class SW_DLLPUBLIC SpzFrameFormat: public SwFrameFormat { + friend ::SwDrawFrameFormat; + friend ::SwFlyFrameFormat; + SpzFrameFormat( + SwAttrPool& rPool, + const OUString& rFormatName, + SwFrameFormat* pDerivedFrame, + sal_uInt16 nFormatWhich) + : SwFrameFormat(rPool, rFormatName, pDerivedFrame, nFormatWhich) + { + assert(nFormatWhich == RES_DRAWFRMFMT || nFormatWhich == RES_FLYFRMFMT); + }; + }; +} // The FlyFrame-Format -class SW_DLLPUBLIC SwFlyFrameFormat final : public SwFrameFormat +class SW_DLLPUBLIC SwFlyFrameFormat final : public sw::SpzFrameFormat { friend class SwDoc; OUString msTitle; @@ -380,7 +405,7 @@ namespace sw }; } -class SW_DLLPUBLIC SwDrawFrameFormat final : public SwFrameFormat +class SW_DLLPUBLIC SwDrawFrameFormat final : public sw::SpzFrameFormat { friend class SwDoc; @@ -396,15 +421,12 @@ class SW_DLLPUBLIC SwDrawFrameFormat final : public SwFrameFormat bool mbPosAttrSet; - SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, - SwFrameFormat *pDrvdFrame ) - : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ), + SwDrawFrameFormat(SwAttrPool& rPool, const OUString& rFormatName, SwFrameFormat* pDerivedFrame) + : sw::SpzFrameFormat(rPool, rFormatName, pDerivedFrame, RES_DRAWFRMFMT), m_pSdrObjectCached(nullptr), - meLayoutDir( SwFrameFormat::HORI_L2R ), - - mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ), - - mbPosAttrSet( false ) + meLayoutDir(SwFrameFormat::HORI_L2R), + mnPositionLayoutDir(css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor), + mbPosAttrSet(false) {} public: diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index ebf329342d8e..2eef22d2b20e 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -42,6 +42,11 @@ namespace com::sun::star::text { class XTextFrame; } +namespace sw +{ +template <class T> class FrameFormats; +class SpzFrameFormat; +} /** * A TextBox is a TextFrame, that is tied to a drawinglayer shape. @@ -165,7 +170,7 @@ public: static void getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough); /// Saves the current shape -> textbox links in a map, so they can be restored later. - static void saveLinks(const SwFrameFormats& rFormats, + static void saveLinks(const sw::FrameFormats<sw::SpzFrameFormat*>& rFormats, std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks); /// Undo the effect of saveLinks() + individual resetLink() calls. static void restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew, diff --git a/sw/qa/core/attr/attr.cxx b/sw/qa/core/attr/attr.cxx index 25d2a8025020..d123ed858b57 100644 --- a/sw/qa/core/attr/attr.cxx +++ b/sw/qa/core/attr/attr.cxx @@ -62,8 +62,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFormatFlySplit) RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize()); SwDoc* pDoc = getSwDoc(); - SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); - SwFrameFormat* pFly = rFlys[0]; + sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormat* pFly = rFlys[0]; CPPUNIT_ASSERT(!pFly->GetAttrSet().GetFlySplit().GetValue()); SfxItemSet aSet(pFly->GetAttrSet()); diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 1597302a5f64..fc1ffc69e8d9 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -55,7 +55,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testMathInsertAnchorType) pShell->InsertObject(svt::EmbeddedObjectRef(), &aGlobalName); // Then the anchor type should be as-char. - SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size()); const SwFrameFormat& rFormat = *rFormats[0]; const SwFormatAnchor& rAnchor = rFormat.GetAnchor(); @@ -72,7 +72,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextboxTextRotateAngle) // Check the writing direction of the only TextFrame in the document. createSwDoc("textbox-textrotateangle.odt"); SwDoc* pDoc = getSwDoc(); - SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFrameFormats.size()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_DRAWFRMFMT), rFrameFormats[0]->Which()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_FLYFRMFMT), rFrameFormats[1]->Which()); @@ -132,9 +132,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextBoxZOrder) { createSwDoc("textbox-zorder.docx"); SwDoc* pDoc = getSwDoc(); - SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), rFormats.size()); - const SwFrameFormat* pEllipse = rFormats[2]; + const sw::SpzFrameFormat* pEllipse = rFormats[2]; const SdrObject* pEllipseShape = pEllipse->FindRealSdrObject(); // Make sure we test the right shape. CPPUNIT_ASSERT_EQUAL(OUString("Shape3"), pEllipseShape->GetName()); @@ -291,10 +291,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testCopyBookmarks) // Also, when checking the # of non-copy images in the resulting doc model: nActual = 0; - SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); - for (size_t i = 0; i < rFrameFormats.size(); ++i) + for (auto pSpz : *pDoc->GetSpzFrameFormats()) { - if (rFrameFormats[i]->GetName().indexOf("Copy") == -1) + if (pSpz->GetName().indexOf("Copy") == -1) { ++nActual; } diff --git a/sw/qa/core/draw/draw.cxx b/sw/qa/core/draw/draw.cxx index 17bedbdbab9c..b77a4ea65d94 100644 --- a/sw/qa/core/draw/draw.cxx +++ b/sw/qa/core/draw/draw.cxx @@ -64,7 +64,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDrawTest, testTextboxUndoOrdNum) createSwDoc("textbox-undo-ordnum.docx"); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFormats = *pDoc->GetSpzFrameFormats(); // Test the state before del + undo. for (const auto& pFormat : rFormats) { diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index f7e6992bf014..1ad1443dd392 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -77,8 +77,8 @@ void Test::Create1x2SplitFly() pWrtShell->EndAllAction(); // Allow the text frame to split: pWrtShell->StartAllAction(); - SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); - SwFrameFormat* pFly = rFlys[0]; + auto& rFlys = *pDoc->GetSpzFrameFormats(); + auto pFly = rFlys[0]; SwAttrSet aSet(pFly->GetAttrSet()); aSet.Put(SwFormatFlySplit(true)); pDoc->SetAttr(aSet, *pFly); diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index e0526bdbb361..f99cc3dd54dd 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -74,7 +74,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxCopyAnchor) pWrtShell->SttEndDoc(/*bStart=*/false); pWrtShell->Paste(aClipboard); - const SwFrameFormats& rFormats = *pShell->GetDoc()->GetSpzFrameFormats(); + const auto& rFormats = *pShell->GetDoc()->GetSpzFrameFormats(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 4 // - Actual : 6 @@ -176,7 +176,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testFlyAnchorUndo) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwDocShell* pShell = pTextDoc->GetDocShell(); SwDoc* pDoc = pShell->GetDoc(); - const SwFrameFormats& rSpz = *pDoc->GetSpzFrameFormats(); + const auto& rSpz = *pDoc->GetSpzFrameFormats(); sal_Int32 nExpected = rSpz[0]->GetAnchor().GetAnchorContentOffset(); // When deleting that last character and undoing it: diff --git a/sw/qa/core/undo/undo.cxx b/sw/qa/core/undo/undo.cxx index 21543416dae8..221f2ba4ece7 100644 --- a/sw/qa/core/undo/undo.cxx +++ b/sw/qa/core/undo/undo.cxx @@ -66,7 +66,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTextboxCutUndo) selectShape(1); rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); pTransfer->Cut(); - SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); + auto& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rSpzFrameFormats.size()); pWrtShell->Undo(); diff --git a/sw/qa/core/view/view.cxx b/sw/qa/core/view/view.cxx index a3fd1863031e..576095c7f4cc 100644 --- a/sw/qa/core/view/view.cxx +++ b/sw/qa/core/view/view.cxx @@ -49,13 +49,11 @@ CPPUNIT_TEST_FIXTURE(Test, testUpdateOleObjectPreviews) pWrtShell->UpdateOleObjectPreviews(); // Then make sure that the working preview of those objects are not lost: - const SwFrameFormats* pFormats = pDoc->GetSpzFrameFormats(); + const auto pFormats = pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(pFormats); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pFormats->size()); - for (size_t i = 0; i < pFormats->size(); ++i) + for (auto pFormat : *pFormats) { - SwFrameFormat* pFormat = (*pFormats)[i]; - const SwNodeIndex* pNodeIndex = pFormat->GetContent().GetContentIdx(); CPPUNIT_ASSERT(pNodeIndex); SwNode* pNode = pDoc->GetNodes()[pNodeIndex->GetIndex() + 1]; diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 93c6598225b1..34900529ada9 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -402,7 +402,7 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf122789) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size()); // This failed, the image had an absolute size, not a relative one. CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(70), rFormats[0]->GetAttrSet().GetFrameSize().GetWidthPercent()); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d69b53fa924c..a0dd296e5e32 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1103,8 +1103,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115094v3) createSwDoc("tdf115094v3.docx"); { SwDoc* pDoc = getSwDoc(); - SwFrameFormats& rSpzFormats = *pDoc->GetSpzFrameFormats(); - SwFrameFormat* pFormat = rSpzFormats[0]; + auto& rSpzFormats = *pDoc->GetSpzFrameFormats(); + auto pFormat = rSpzFormats[0]; // Without the fix, this has failed with: // - Expected: 1991 // - Actual : 1883 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index a1610c35dbbb..491626ff7812 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -324,7 +324,7 @@ DECLARE_OOXMLEXPORT_TEST(testBtlrShape, "btlr-textbox.docx") SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_DRAWFRMFMT), rFormats[0]->Which()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_FLYFRMFMT), rFormats[1]->Which()); diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index 3ae9fa470000..0213d0b893b7 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -243,7 +243,7 @@ DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, "anchor.fodt") CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getParagraph(1)->getString()); - SwFrameFormats& rFlys(*pDoc->GetSpzFrameFormats()); + auto& rFlys = *pDoc->GetSpzFrameFormats(); if (isExported()) { // 2, not 3: the form control becomes a field on export... CPPUNIT_ASSERT_EQUAL(size_t(2), rFlys.size()); diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 492de89912bc..1833b1220dbd 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -753,7 +753,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137245) CPPUNIT_ASSERT(pFly != nullptr); } - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rFormats.size()); // move cursor back to body @@ -2692,12 +2692,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf122942) pWrtShell->EndCreate(SdrCreateCmd::ForceEnd); // Make sure that the shape is inserted. - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size()); reload("writer8", "tdf122942.odt"); pDoc = getSwDoc(); - const SwFrameFormats& rFormats2 = *pDoc->GetSpzFrameFormats(); + const auto& rFormats2 = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats2.size()); // Make sure the top of the inserted shape does not move outside the existing shape, even after diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index a0356dfec4e5..b7a9a08d4316 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1459,10 +1459,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testShapePageMove) { &aXItem, &aYItem }); // Check if the shape anchor was moved to the 2nd page as well. - SwFrameFormats* pShapeFormats = pDoc->GetSpzFrameFormats(); + auto pShapeFormats = pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(!pShapeFormats->empty()); auto it = pShapeFormats->begin(); - SwFrameFormat* pShapeFormat = *it; + auto pShapeFormat = *it; const SwPosition* pAnchor = pShapeFormat->GetAnchor().GetContentAnchor(); CPPUNIT_ASSERT(pAnchor); @@ -2798,7 +2798,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128603) rUndoManager.Undo(); // Make sure the content indexes still match. - const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); + const auto& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), rSpzFrameFormats.size()); const SwNodeIndex* pIndex4 = rSpzFrameFormats[4]->GetContent().GetContentIdx(); CPPUNIT_ASSERT(pIndex4); diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 65a1352dc79b..81a6d9e25fc2 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -1072,7 +1072,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf130805) createSwDoc("tdf130805.odt"); SwDoc* pDoc = getSwDoc(); - const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); auto pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); @@ -1097,9 +1097,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf107893) SwDoc* pDoc = getSwDoc(); //Get the format of the shape - const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); - SwFrameFormat* pShape = rFrmFormats.front(); + auto pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); //Add a textbox @@ -1150,9 +1150,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, TestTextBoxCrashAfterLineDel) SwDoc* pDoc = getSwDoc(); // Get the format of the shape - const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); - SwFrameFormat* pShape = rFrmFormats.front(); + auto pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); // Add a textbox @@ -1974,7 +1974,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, AtPageTextBoxCrash) SwDoc* pDoc = getSwDoc(); // Get the format of the shape - const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); auto pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index f4274a629d39..d248c6ce6b26 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -689,10 +689,10 @@ DECLARE_WW8EXPORT_TEST(testTdf112535, "tdf112535.doc") SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); CPPUNIT_ASSERT(pDoc->GetSpzFrameFormats()); - SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + auto& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(!rFormats.empty()); - const SwFrameFormat* pFormat = rFormats[0]; + const auto pFormat = rFormats[0]; CPPUNIT_ASSERT(pFormat); // Without the accompanying fix in place, this test would have failed: auto-contour was enabled diff --git a/sw/qa/filter/html/html.cxx b/sw/qa/filter/html/html.cxx index 6cd714bbdd48..523bc49a4358 100644 --- a/sw/qa/filter/html/html.cxx +++ b/sw/qa/filter/html/html.cxx @@ -65,8 +65,8 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspect) // Then make sure that the aspect ratio of the image is kept: auto pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwDoc* pDoc = pTextDocument->GetDocShell()->GetDoc(); - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); - const SwFrameFormat* pFormat = rFormats[0]; + const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const auto pFormat = rFormats[0]; const SwFormatFrameSize& rSize = pFormat->GetFrameSize(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 255 @@ -86,8 +86,8 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspectImage) // Then make sure that the aspect ratio of the image is kept: auto pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwDoc* pDoc = pTextDocument->GetDocShell()->GetDoc(); - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); - const SwFrameFormat* pFormat = rFormats[0]; + const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const auto pFormat = rFormats[0]; const SwFormatFrameSize& rSize = pFormat->GetFrameSize(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 255 diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index a83bd12431df..b732a37eff40 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -214,8 +214,8 @@ CPPUNIT_TEST_FIXTURE(Test, testDocxFloatingTableExport) pWrtShell->StartAllAction(); aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize()); // Mark it as a floating table: - SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); - SwFrameFormat* pFly = rFlys[0]; + auto& rFlys = *pDoc->GetSpzFrameFormats(); + auto pFly = rFlys[0]; SwAttrSet aSet(pFly->GetAttrSet()); aSet.Put(SwFormatFlySplit(true)); pDoc->SetAttr(aSet, *pFly); diff --git a/sw/qa/uibase/docvw/docvw.cxx b/sw/qa/uibase/docvw/docvw.cxx index 677a5abd2a54..280a0459109e 100644 --- a/sw/qa/uibase/docvw/docvw.cxx +++ b/sw/qa/uibase/docvw/docvw.cxx @@ -48,7 +48,7 @@ CPPUNIT_TEST_FIXTURE(Test, testShiftClickOnImage) pWrtShell->SttEndDoc(/*bStt=*/false); // When shift-clicking on that fly frame: - SwFrameFormats& rSpzFormats = *pDoc->GetSpzFrameFormats(); + auto& rSpzFormats = *pDoc->GetSpzFrameFormats(); auto pFrameFormat = dynamic_cast<SwFlyFrameFormat*>(rSpzFormats[0]); CPPUNIT_ASSERT(pFrameFormat); SwFlyFrame* pFlyFrame = pFrameFormat->GetFrame(); @@ -163,7 +163,7 @@ CPPUNIT_TEST_FIXTURE(Test, testShiftDoubleClickOnImage) xRegistration->registerDispatchProviderInterceptor(pInterceptor); // When shift-double-clicking on that fly frame: - SwFrameFormats& rSpzFormats = *pDoc->GetSpzFrameFormats(); + auto& rSpzFormats = *pDoc->GetSpzFrameFormats(); auto pFrameFormat = dynamic_cast<SwFlyFrameFormat*>(rSpzFormats[0]); CPPUNIT_ASSERT(pFrameFormat); SwFlyFrame* pFlyFrame = pFrameFormat->GetFrame(); diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx index b9f03d42d5ee..6ad35e07466a 100644 --- a/sw/qa/uibase/uno/uno.cxx +++ b/sw/qa/uibase/uno/uno.cxx @@ -149,8 +149,8 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testCreateTextRangeByPixelPositionGraphic) = xController->createTextRangeByPixelPosition(aPoint); // Then make sure that the anchor of the image is returned: - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); - const SwFrameFormat* pFormat = rFormats[0]; + const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const auto pFormat = rFormats[0]; SwPosition aAnchorPos(*pFormat->GetAnchor().GetContentAnchor()); auto pTextRange = dynamic_cast<SwXTextRange*>(xTextRange.get()); SwPaM aPaM(pDoc->GetNodes()); diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index c8b1e3d8513a..3ea5db46ccc9 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -2749,10 +2749,9 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext ) // then check all the Flys with a URL or image map { - const SwFrameFormats* pFormats = GetDoc()->GetSpzFrameFormats(); - for( SwFrameFormats::size_type n = 0, nEnd = pFormats->size(); n < nEnd; ++n ) + for(sw::SpzFrameFormat* pSpz: *GetDoc()->GetSpzFrameFormats()) { - SwFlyFrameFormat* pFormat = static_cast<SwFlyFrameFormat*>((*pFormats)[ n ]); + auto pFormat = static_cast<SwFlyFrameFormat*>(pSpz); const SwFormatURL& rURLItem = pFormat->GetURL(); if( rURLItem.GetMap() || !rURLItem.GetURL().isEmpty() ) { diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx index dd71aba69cc9..d87e0c2f2374 100644 --- a/sw/source/core/doc/CntntIdxStore.cxx +++ b/sw/source/core/doc/CntntIdxStore.cxx @@ -370,12 +370,12 @@ void ContentIdxStoreImpl::SaveFlys(SwDoc& rDoc, SwNodeOffset nNode, sal_Int32 nC void ContentIdxStoreImpl::RestoreFlys(SwDoc& rDoc, updater_t const & rUpdater, bool bAuto, bool bAtStart) { - SwFrameFormats* pSpz = rDoc.GetSpzFrameFormats(); + sw::SpzFrameFormats* pSpz = rDoc.GetSpzFrameFormats(); for (const MarkEntry& aEntry : m_aFlyEntries) { if(!aEntry.m_bOther) { - SwFrameFormat *pFrameFormat = (*pSpz)[ aEntry.m_nIdx ]; + sw::SpzFrameFormat* pFrameFormat = (*pSpz)[ aEntry.m_nIdx ]; const SwFormatAnchor& rFlyAnchor = pFrameFormat->GetAnchor(); if( rFlyAnchor.GetContentAnchor() ) { diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 3d86d7ffec8f..3a158e26a9a1 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -101,11 +101,9 @@ namespace bool lcl_ChkFlyFly( SwDoc& rDoc, SwNodeOffset nSttNd, SwNodeOffset nEndNd, SwNodeOffset nInsNd ) { - const SwFrameFormats& rFrameFormatTable = *rDoc.GetSpzFrameFormats(); - for( size_t n = 0; n < rFrameFormatTable.size(); ++n ) + for(sw::SpzFrameFormat* pFormat: *rDoc.GetSpzFrameFormats()) { - SwFrameFormat const*const pFormat = rFrameFormatTable[n]; SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && @@ -2310,7 +2308,7 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam ) // If there are FlyFrames left, delete these too for( size_t n = 0; n < m_rDoc.GetSpzFrameFormats()->size(); ++n ) { - SwFrameFormat* pFly = (*m_rDoc.GetSpzFrameFormats())[n]; + sw::SpzFrameFormat* pFly = (*m_rDoc.GetSpzFrameFormats())[n]; const SwFormatAnchor* pAnchor = &pFly->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index e0366bdd3a0b..6959b7c7ba3a 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -248,20 +248,19 @@ void DocumentLayoutManager::DelLayoutFormat( SwFrameFormat *pFormat ) pContentIdx = pFormat->GetContent().GetContentIdx(); if (pContentIdx) { - const SwFrameFormats* pTable = pFormat->GetDoc()->GetSpzFrameFormats(); - if ( pTable ) + sw::SpzFrameFormats* pSpzs = pFormat->GetDoc()->GetSpzFrameFormats(); + if ( pSpzs ) { std::vector<SwFrameFormat*> aToDeleteFrameFormats; const SwNodeOffset nNodeIdxOfFlyFormat( pContentIdx->GetIndex() ); - for ( size_t i = 0; i < pTable->size(); ++i ) + for(sw::SpzFrameFormat* pSpz: *pSpzs) { - SwFrameFormat* pTmpFormat = (*pTable)[i]; - const SwFormatAnchor &rAnch = pTmpFormat->GetAnchor(); + const SwFormatAnchor &rAnch = pSpz->GetAnchor(); if ( rAnch.GetAnchorId() == RndStdIds::FLY_AT_FLY && rAnch.GetAnchorNode()->GetIndex() == nNodeIdxOfFlyFormat ) { - aToDeleteFrameFormats.push_back( pTmpFormat ); + aToDeleteFrameFormats.push_back(pSpz); } } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 8b1f18348796..1c8e5327d4aa 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -407,15 +407,14 @@ static OUString lcl_AnchoredFrames(const SwNode & rNode) OUStringBuffer aResult("["); const SwDoc& rDoc = rNode.GetDoc(); - const SwFrameFormats * pFrameFormats = rDoc.GetSpzFrameFormats(); + const sw::SpzFrameFormats* pSpzs = rDoc.GetSpzFrameFormats(); - if (pFrameFormats) + if (pSpzs) { bool bFirst = true; - for (SwFrameFormats::const_iterator i(pFrameFormats->begin()); - i != pFrameFormats->end(); ++i) + for(const sw::SpzFrameFormat* pSpz: *pSpzs) { - const SwFormatAnchor & rAnchor = (*i)->GetAnchor(); + const SwFormatAnchor& rAnchor = pSpz->GetAnchor(); const SwNode * pPos = rAnchor.GetAnchorNode(); if (pPos && *pPos == rNode) @@ -423,8 +422,8 @@ static OUString lcl_AnchoredFrames(const SwNode & rNode) if (! bFirst) aResult.append(", "); - if (*i) - aResult.append(lcl_dbg_out(**i)); + if (pSpz) + aResult.append(lcl_dbg_out(*pSpz)); bFirst = false; } } diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index 6bf54c6b6e5a..c28a15f12bf5 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -157,10 +157,10 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall case EVENT_OBJECT_URLITEM: case EVENT_OBJECT_IMAGE: { - const SwFrameFormat* pFormat = rCallEvent.PTR.pFormat; + const auto pSpz = static_cast<const sw::SpzFrameFormat*>(rCallEvent.PTR.pFormat); if( bCheckPtr ) { - if (GetSpzFrameFormats()->IsAlive(pFormat)) + if (GetSpzFrameFormats()->IsAlive(pSpz)) bCheckPtr = false; // misuse as a flag else // this shouldn't be possible now that SwCallMouseEvent @@ -168,7 +168,7 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall assert(false); } if( !bCheckPtr ) - pTable = &pFormat->GetMacro().GetMacroTable(); + pTable = &pSpz->GetMacro().GetMacroTable(); } break; @@ -177,10 +177,10 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall const IMapObject* pIMapObj = rCallEvent.PTR.IMAP.pIMapObj; if( bCheckPtr ) { - const SwFrameFormat* pFormat = rCallEvent.PTR.IMAP.pFormat; - if (GetSpzFrameFormats()->IsAlive(pFormat)) + const auto pSpz = static_cast<const sw::SpzFrameFormat*>(rCallEvent.PTR.IMAP.pFormat); + if (GetSpzFrameFormats()->IsAlive(pSpz)) { - const ImageMap* pIMap = pFormat->GetURL().GetMap(); + const ImageMap* pIMap = pSpz->GetURL().GetMap(); if (pIMap) { for( size_t nPos = pIMap->GetIMapObjectCount(); nPos; ) diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 1779ec998300..2941112bc5d8 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1795,14 +1795,14 @@ namespace std::make_shared<CompareMainText>(rDestDoc, true)); //if we have the same number of frames then try to compare within them - const SwFrameFormats *pSrcFrameFormats = rSrcDoc.GetSpzFrameFormats(); - const SwFrameFormats *pDestFrameFormats = rDestDoc.GetSpzFrameFormats(); + const sw::SpzFrameFormats* pSrcFrameFormats = rSrcDoc.GetSpzFrameFormats(); + const sw::SpzFrameFormats* pDestFrameFormats = rDestDoc.GetSpzFrameFormats(); if (pSrcFrameFormats->size() == pDestFrameFormats->size()) { - for (size_t i = 0; i < pSrcFrameFormats->size(); ++i) + for(sw::FrameFormats<sw::SpzFrameFormat*>::size_type i = 0; i < pSrcFrameFormats->size(); ++i) { - const SwFrameFormat& rSrcFormat = *(*pSrcFrameFormats)[i]; - const SwFrameFormat& rDestFormat = *(*pDestFrameFormats)[i]; + const sw::SpzFrameFormat& rSrcFormat = *(*pSrcFrameFormats)[i]; + const sw::SpzFrameFormat& rDestFormat = *(*pDestFrameFormats)[i]; const SwNodeIndex* pSrcIdx = rSrcFormat.GetContent().GetContentIdx(); const SwNodeIndex* pDestIdx = rDestFormat.GetContent().GetContentIdx(); if (!pSrcIdx && !pDestIdx) diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index a93000b679fc..3994f2af8aac 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -93,7 +93,7 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwPosition& rStartPos, } aAnchor.SetAnchor( &aPos ); - pFormat->GetDoc()->GetSpzFrameFormats()->push_back( pFormat ); + pFormat->GetDoc()->GetSpzFrameFormats()->push_back(static_cast<sw::SpzFrameFormat*>(pFormat)); // SetFormatAttr should call Modify() and add it to the node pFormat->SetFormatAttr( aAnchor ); SwContentNode* pCNd = aPos.GetNode().GetContentNode(); @@ -105,11 +105,11 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwPosition& rStartPos, void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ) { - SwFrameFormats& rFormats = *rRg.aStart.GetNode().GetDoc().GetSpzFrameFormats(); - for( SwFrameFormats::size_type n = 0; n < rFormats.size(); ++n ) + sw::SpzFrameFormats& rSpzs = *rRg.aStart.GetNode().GetDoc().GetSpzFrameFormats(); + for(sw::FrameFormats<sw::SpzFrameFormat*>::size_type n = 0; n < rSpzs.size(); ++n ) { - SwFrameFormat *const pFormat = rFormats[n]; - SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); + auto pSpz = rSpzs[n]; + SwFormatAnchor const*const pAnchor = &pSpz->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) || @@ -120,14 +120,14 @@ void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ) (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId()) ? pAnchor->GetAnchorContentOffset() : 0, - pFormat, false ); + pSpz, false ); rArr.push_back( aSave ); - pFormat->DelFrames(); + pSpz->DelFrames(); // set a dummy anchor position to maintain anchoring invariants - SwFormatAnchor aAnchor( pFormat->GetAnchor() ); + SwFormatAnchor aAnchor( pSpz->GetAnchor() ); aAnchor.SetAnchor(nullptr); - pFormat->SetFormatAttr(aAnchor); - rFormats.erase( rFormats.begin() + n-- ); + pSpz->SetFormatAttr(aAnchor); + rSpzs.erase( rSpzs.begin() + n-- ); } } sw::CheckAnchoredFlyConsistency(rRg.aStart.GetNode().GetDoc()); @@ -136,8 +136,8 @@ void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ) void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos, SaveFlyArr& rArr, bool bMoveAllFlys, SwHistory *const pHistory) { - SwFrameFormats& rFormats = *rPam.GetPoint()->GetNode().GetDoc().GetSpzFrameFormats(); - SwFrameFormat* pFormat; + sw::SpzFrameFormats& rFormats = *rPam.GetPoint()->GetNode().GetDoc().GetSpzFrameFormats(); + sw::SpzFrameFormat* pFormat; const SwFormatAnchor* pAnchor; const SwPosition* pPos = rPam.Start(); @@ -220,10 +220,10 @@ void DelFlyInRange( SwNode& rMkNd, SwPosition const& rEnd = mark <= point ? point : mark; SwDoc& rDoc = rMkNd.GetDoc(); - SwFrameFormats& rTable = *rDoc.GetSpzFrameFormats(); + sw::SpzFrameFormats& rTable = *rDoc.GetSpzFrameFormats(); for ( auto i = rTable.size(); i; ) { - SwFrameFormat *pFormat = rTable[--i]; + sw::SpzFrameFormat* pFormat = rTable[--i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); SwPosition const*const pAPos = rAnch.GetContentAnchor(); if (pAPos && @@ -248,7 +248,7 @@ void DelFlyInRange( SwNode& rMkNd, if (i > rTable.size()) i = rTable.size(); else if (i == rTable.size() || pFormat != rTable[i]) - i = std::distance(rTable.begin(), rTable.find( pFormat )); + i = std::distance(rTable.begin(), rTable.find(pFormat)); } rDoc.getIDocumentLayoutAccess().DelLayoutFormat( pFormat ); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 998f123ee6c0..1d425e62f73d 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -67,15 +67,11 @@ using namespace ::com::sun::star; size_t SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const { - const SwFrameFormats& rFormats = *GetSpzFrameFormats(); - const size_t nSize = rFormats.size(); size_t nCount = 0; const SwNodeIndex* pIdx; - for ( size_t i = 0; i < nSize; ++i) + for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats()) { - const SwFrameFormat* pFlyFormat = rFormats[ i ]; - if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) continue; @@ -114,16 +110,12 @@ size_t SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const /// @attention If you change this, also update SwXFrameEnumeration in unocoll. SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes ) { - SwFrameFormats& rFormats = *GetSpzFrameFormats(); SwFrameFormat* pRetFormat = nullptr; - const size_t nSize = rFormats.size(); const SwNodeIndex* pIdx; size_t nCount = 0; - for( size_t i = 0; !pRetFormat && i < nSize; ++i ) + for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats()) { - SwFrameFormat* pFlyFormat = rFormats[ i ]; - if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) continue; @@ -159,16 +151,11 @@ SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreText std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats( FlyCntType const eType, bool const bIgnoreTextBoxes) { - SwFrameFormats& rFormats = *GetSpzFrameFormats(); - const size_t nSize = rFormats.size(); - std::vector<SwFrameFormat const*> ret; - ret.reserve(nSize); + ret.reserve(GetSpzFrameFormats()->size()); - for (size_t i = 0; i < nSize; ++i) + for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats()) { - SwFrameFormat const*const pFlyFormat = rFormats[ i ]; - if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) { continue; @@ -1025,7 +1012,7 @@ SwChainRet SwDoc::Chainable( const SwFrameFormat &rSource, const SwFrameFormat & return SwChainRet::NOT_EMPTY; } - for( auto pSpzFrameFm : *GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pSpzFrameFm: *GetSpzFrameFormats()) { const SwFormatAnchor& rAnchor = pSpzFrameFm->GetAnchor(); // #i20622# - to-frame anchored objects are allowed. diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index aa737661d6dc..a0111f537469 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -723,13 +723,14 @@ void SwDoc::DelFrameFormat( SwFrameFormat *pFormat, bool bBroadcast ) } else { - bool contains = GetSpzFrameFormats()->ContainsFormat(*pFormat); - OSL_ENSURE( contains, "FrameFormat not found." ); - if( contains ) + auto pSpz = static_cast<sw::SpzFrameFormat*>(pFormat); + if(GetSpzFrameFormats()->ContainsFormat(pSpz)) { - GetSpzFrameFormats()->erase( pFormat ); - delete pFormat; + GetSpzFrameFormats()->erase(pSpz); + delete pSpz; } + else + SAL_WARN("sw", "FrameFormat not found."); } } } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index d37c5dc59d3c..eab0204fd605 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -488,7 +488,7 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso, SwPosFlyFrames aRetval; // collect all anchored somehow to paragraphs - for( auto pFly : *GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pFly: *GetSpzFrameFormats()) { bool bDrawFormat = bDrawAlso && RES_DRAWFRMFMT == pFly->Which(); bool bFlyFormat = RES_FLYFRMFMT == pFly->Which(); @@ -1337,14 +1337,11 @@ static OUString lcl_GetUniqueFlyName(const SwDoc& rDoc, TranslateId pDefStrId, s OUString aName(SwResId(pDefStrId)); sal_Int32 nNmLen = aName.getLength(); - const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); - std::vector<unsigned int> aUsedNums; - aUsedNums.reserve(rFormats.size()); + aUsedNums.reserve(rDoc.GetSpzFrameFormats()->size()); - for( SwFrameFormats::size_type n = 0; n < rFormats.size(); ++n ) + for(sw::SpzFrameFormat* pFlyFormat: *rDoc.GetSpzFrameFormats()) { - const SwFrameFormat* pFlyFormat = rFormats[ n ]; if (eType != pFlyFormat->Which()) continue; if (eType == RES_DRAWFRMFMT) @@ -1564,7 +1561,7 @@ bool SwDoc::IsInHeaderFooter( const SwNode& rIdx ) const // get up by using the Anchor #if OSL_DEBUG_LEVEL > 0 std::vector<const SwFrameFormat*> checkFormats; - for( auto pFormat : *GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pFormat: *GetSpzFrameFormats()) { const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if( pIdx && pFlyNd == &pIdx->GetNode() ) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 5884616e9ee9..bfc8c71dfe48 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -234,7 +234,7 @@ SwDoc::SwDoc() mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), "Graphikformatvorlage" ) ), mpFrameFormatTable( new SwFrameFormats() ), mpCharFormatTable( new SwCharFormats ), - mpSpzFrameFormatTable( new SwFrameFormats() ), + mpSpzFrameFormatTable( new sw::FrameFormats<sw::SpzFrameFormat*>() ), mpSectionFormatTable( new SwSectionFormats ), mpTableFrameFormatTable( new sw::TableFrameFormats() ), mpTextFormatCollTable( new SwTextFormatColls() ), @@ -1291,7 +1291,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu } // finally copy page bound frames - for ( auto pCpyFormat : *rSource.GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pCpyFormat: *rSource.GetSpzFrameFormats()) { const SwFrameFormat& rCpyFormat = *pCpyFormat; SwFormatAnchor aAnchor( rCpyFormat.GetAnchor() ); diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 3601c119bbb3..d22ab372e323 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -286,7 +286,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) auto [pStart, pEnd] = rPaM.StartEnd(); // SwPosition* // Set index to the Selection's start - for ( const auto *pFormat : *GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pFormat: *GetSpzFrameFormats()) { SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index c39d9c387a3c..0b11ea6c80d2 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -540,7 +540,7 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, } // If we still have FlyFrames hanging around, delete them too - for( const auto pFly : *pDoc->GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pFly: *pDoc->GetSpzFrameFormats()) { SwFormatAnchor const*const pAnchor = &pFly->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 98fc0512acfd..e87a28ba4cfd 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -349,8 +349,7 @@ sal_Int32 SwTextBoxHelper::getCount(SdrPage const* pPage) sal_Int32 SwTextBoxHelper::getCount(const SwDoc& rDoc) { sal_Int32 nRet = 0; - const SwFrameFormats& rSpzFrameFormats = *rDoc.GetSpzFrameFormats(); - for (const auto pFormat : rSpzFrameFormats) + for (const sw::SpzFrameFormat* pFormat : *rDoc.GetSpzFrameFormats()) { if (isTextBox(pFormat, RES_FLYFRMFMT)) ++nRet; @@ -960,7 +959,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u xPropertySet->setPropertyValue(aPropertyName, aValue); } -void SwTextBoxHelper::saveLinks(const SwFrameFormats& rFormats, +void SwTextBoxHelper::saveLinks(const sw::FrameFormats<sw::SpzFrameFormat*>& rFormats, std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks) { for (const auto pFormat : rFormats) diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index b9ae26a0e421..8e055c5242bc 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1662,8 +1662,7 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // #i28006# Fly frames have to be restored even if the table was // #alone in the section - const SwFrameFormats& rFlyArr = *GetDoc().GetSpzFrameFormats(); - for( auto pFly : rFlyArr ) + for(sw::SpzFrameFormat* pFly: *GetDoc().GetSpzFrameFormats()) { SwFrameFormat *const pFormat = pFly; const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 91ac1697ea30..b69dec062a1f 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -547,16 +547,15 @@ const SwPageDesc* SwNode::FindPageDesc( SwNodeOffset* pPgDescNdIdx ) const { // Find the right Anchor first const SwFrameFormat* pFormat = nullptr; - const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); + const sw::SpzFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); - for( size_t n = 0; n < rFormats.size(); ++n ) + for(sw::SpzFrameFormat* pSpz: rFormats) { - const SwFrameFormat* pFrameFormat = rFormats[ n ]; - const SwFormatContent& rContent = pFrameFormat->GetContent(); + const SwFormatContent& rContent = pSpz->GetContent(); if( rContent.GetContentIdx() && &rContent.GetContentIdx()->GetNode() == static_cast<SwNode const *>(pSttNd) ) { - pFormat = pFrameFormat; + pFormat = pSpz; break; } } @@ -751,18 +750,17 @@ SwFrameFormat* SwNode::GetFlyFormat() const if( !pRet ) { // The hard way through the Doc is our last way out - const SwFrameFormats& rFrameFormatTable = *GetDoc().GetSpzFrameFormats(); - for( size_t n = 0; n < rFrameFormatTable.size(); ++n ) + const sw::SpzFrameFormats& rSpzs = *GetDoc().GetSpzFrameFormats(); + for(sw::SpzFrameFormat* pSpz: rSpzs) { - SwFrameFormat* pFormat = rFrameFormatTable[n]; // Only Writer fly frames can contain Writer nodes. - if (pFormat->Which() != RES_FLYFRMFMT) + if (pSpz->Which() != RES_FLYFRMFMT) continue; - const SwFormatContent& rContent = pFormat->GetContent(); + const SwFormatContent& rContent = pSpz->GetContent(); if( rContent.GetContentIdx() && &rContent.GetContentIdx()->GetNode() == pSttNd ) { - pRet = pFormat; + pRet = pSpz; break; } } diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 8e26a42af34f..456241b660c0 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -751,10 +751,10 @@ SwDrawContact::~SwDrawContact() void SwDrawContact::GetTextObjectsFromFormat(std::list<SdrTextObj*>& o_rTextObjects, SwDoc& rDoc) { - for(auto& rpFly : *rDoc.GetSpzFrameFormats()) + for(sw::SpzFrameFormat* pFly: *rDoc.GetSpzFrameFormats()) { - if(dynamic_cast<const SwDrawFrameFormat*>(rpFly)) - rpFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects)); + if(dynamic_cast<const SwDrawFrameFormat*>(pFly)) + pFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects)); } } @@ -1878,8 +1878,7 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) else { const SwNode& rIdx = *pAnch->GetAnchorNode(); - SwFrameFormats& rFormats = *(pDrawFrameFormat->GetDoc()->GetSpzFrameFormats()); - for( auto pFlyFormat : rFormats ) + for(sw::SpzFrameFormat* pFlyFormat :*(pDrawFrameFormat->GetDoc()->GetSpzFrameFormats())) { if( pFlyFormat->GetContent().GetContentIdx() && rIdx == pFlyFormat->GetContent().GetContentIdx()->GetNode() ) diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index beb014cd5fc4..d0be7aa0d515 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -93,7 +93,7 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText ) } // also delete surrounding FlyFrames if any - for( const auto pFly : *rClpDoc.GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pFly : *rClpDoc.GetSpzFrameFormats() ) { SwFormatAnchor const*const pAnchor = &pFly->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); @@ -144,13 +144,13 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText ) // assure the "RootFormat" is the first element in Spz-Array // (if necessary Flys were copied in Flys) - SwFrameFormats& rSpzFrameFormats = *rClpDoc.GetSpzFrameFormats(); + sw::SpzFrameFormats& rSpzFrameFormats = *rClpDoc.GetSpzFrameFormats(); if( rSpzFrameFormats[ 0 ] != pFlyFormat ) { #ifndef NDEBUG bool inserted = #endif - rSpzFrameFormats.newDefault( pFlyFormat ); + rSpzFrameFormats.newDefault(static_cast<sw::SpzFrameFormat*>(pFlyFormat)); assert( !inserted && "Fly not contained in Spz-Array" ); } @@ -687,7 +687,7 @@ namespace { return false; } - for ( const auto& pSpzFormat : *pFormat->GetDoc()->GetSpzFrameFormats() ) + for(const sw::SpzFrameFormat* pSpzFormat: *pFormat->GetDoc()->GetSpzFrameFormats()) { if (pSpzFormat->Which() != RES_FLYFRMFMT) { @@ -1042,7 +1042,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable) if(!Imp()->GetDrawView()) MakeDrawView(); ::std::vector<SwFrameFormat*> inserted; - for (auto const pFlyFormat : *rClpDoc.GetSpzFrameFormats()) + for (sw::SpzFrameFormat* pFlyFormat: *rClpDoc.GetSpzFrameFormats()) { // if anchored inside other fly, will be copied when copying // top-level fly, so skip here! (other non-body anchor @@ -1202,7 +1202,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1 if( !rToFill.Imp()->GetDrawView() ) rToFill.MakeDrawView(); - for ( auto pCpyFormat : *GetDoc()->GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pCpyFormat: *GetDoc()->GetSpzFrameFormats()) { SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() ); if ((RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) && diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 3e1bb21df9f8..92f41ef0597e 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -1004,7 +1004,7 @@ void SwFEShell::GetPageObjs( std::vector<SwFrameFormat*>& rFillArr ) { rFillArr.clear(); - for( auto pFormat : *mxDoc->GetSpzFrameFormats() ) + for(sw::SpzFrameFormat* pFormat : *mxDoc->GetSpzFrameFormats() ) { if (RndStdIds::FLY_AT_PAGE == pFormat->GetAnchor().GetAnchorId()) { @@ -1026,7 +1026,7 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr ) bool bTmpAssert = false; for( auto pFormat : rFillArr ) { - if (mxDoc->GetSpzFrameFormats()->IsAlive(pFormat)) + if (mxDoc->GetSpzFrameFormats()->IsAlive(static_cast<sw::SpzFrameFormat*>(pFormat))) { // FlyFormat is still valid, therefore process @@ -1443,7 +1443,7 @@ SwFrameFormat* SwFEShell::WizardGetFly() { // do not search the Fly via the layout. Now we can delete a frame // without a valid layout. ( e.g. for the wizards ) - SwFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats(); if( !rSpzArr.empty() ) { SwNode& rCursorNd = GetCursor()->GetPoint()->GetNode(); diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 01022e60a7d9..48a92366509c 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -901,7 +901,7 @@ bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) if( bRet ) { // now check for paragraph bound flies - const SwFrameFormats& rFormats = *rPam.GetDoc().GetSpzFrameFormats(); + const sw::SpzFrameFormats& rFormats = *rPam.GetDoc().GetSpzFrameFormats(); SwNodeOffset nSttIdx = rPam.GetPoint()->GetNodeIndex(), nEndIdx = rBox.GetSttNd()->EndOfSectionIndex(), nIdx; diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index ca3c787e3954..3c8966f3147b 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_SOURCE_CORE_INC_FRMTOOL_HXX #include <swtypes.hxx> +#include <frameformats.hxx> #include <BorderCacheOwner.hxx> #include "frame.hxx" #include "txtfrm.hxx" @@ -56,10 +57,9 @@ constexpr tools::Long BROWSE_HEIGHT = 56700 * 10; // 10 Meters #define GRFNUM_YES 1 #define GRFNUM_REPLACE 2 -void AppendObjs( const SwFrameFormats *pTable, SwNodeOffset nIndex, - SwFrame *pFrame, SwPageFrame *pPage, SwDoc* doc ); +void AppendObjs(const sw::FrameFormats<sw::SpzFrameFormat*>* pSpz, SwNodeOffset nIndex, SwFrame* pFrame, SwPageFrame* pPage, SwDoc* doc); -void AppendObjsOfNode(SwFrameFormats const* pTable, SwNodeOffset nIndex, +void AppendObjsOfNode(sw::FrameFormats<sw::SpzFrameFormat*> const* pTable, SwNodeOffset nIndex, SwFrame * pFrame, SwPageFrame * pPage, SwDoc * pDoc, std::vector<sw::Extent>::const_iterator const* pIter, std::vector<sw::Extent>::const_iterator const* pEnd, @@ -72,7 +72,7 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode, bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor); -void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib); +void AppendAllObjs(const sw::FrameFormats<sw::SpzFrameFormat*>* pSpzs, const SwFrame* pSib); // draw background with brush or graphics // The 6th parameter indicates that the method should consider background diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx index 3d3b224d03a5..20fa600a6301 100644 --- a/sw/source/core/inc/rolbck.hxx +++ b/sw/source/core/inc/rolbck.hxx @@ -33,6 +33,9 @@ namespace sfx2 { class MetadatableUndo; } +namespace sw { + class SpzFrameFormat; +} class SwDoc; class SwFormatColl; @@ -317,12 +320,12 @@ public: class SwHistoryChangeFlyAnchor final : public SwHistoryHint { - SwFrameFormat & m_rFormat; + sw::SpzFrameFormat& m_rFormat; // despite the name, this is not only used for flys, but also for draw formats(!) const SwNodeOffset m_nOldNodeIndex; const sal_Int32 m_nOldContentIndex; public: - SwHistoryChangeFlyAnchor( SwFrameFormat& rFormat ); + SwHistoryChangeFlyAnchor(sw::SpzFrameFormat& rFormat); virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override; }; @@ -370,7 +373,7 @@ public: void Add( SwTextAttr* pTextHt, SwNodeOffset nNodeIdx, bool bNewAttr ); void Add( SwFormatColl*, SwNodeOffset nNodeIdx, SwNodeType nWhichNd ); void Add( const ::sw::mark::IMark&, bool bSavePos, bool bSaveOtherPos ); - void AddChangeFlyAnchor( SwFrameFormat& rFormat ); + void AddChangeFlyAnchor(sw::SpzFrameFormat& rFormat); void AddDeleteFly( SwFrameFormat&, sal_uInt16& rSetPos ); void Add( const SwTextFootnote& ); void Add( const SfxItemSet & rSet, const SwCharFormat & rCharFormat); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index b0f07c59f62b..b81a2fab65a9 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2835,15 +2835,12 @@ bool SwFrameFormat::IsLowerOf( const SwFrameFormat& rFormat ) const const SwFormatAnchor* pAnchor = &rFormat.GetAnchor(); if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetAnchorNode()) { - const SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats(); const SwNode* pFlyNd = pAnchor->GetAnchorNode()->FindFlyStartNode(); while( pFlyNd ) { // then we walk up using the anchor - size_t n; - for( n = 0; n < rFormats.size(); ++n ) + for(const sw::SpzFrameFormat* pFormat: *GetDoc()->GetSpzFrameFormats()) { - const SwFrameFormat* pFormat = rFormats[ n ]; const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if( pIdx && pFlyNd == &pIdx->GetNode() ) { @@ -2861,11 +2858,6 @@ bool SwFrameFormat::IsLowerOf( const SwFrameFormat& rFormat ) const break; } } - if( n >= rFormats.size() ) - { - OSL_ENSURE( false, "Fly section but no format found" ); - return false; - } } } return false; @@ -2939,8 +2931,8 @@ void SwFrameFormats::dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) cons } -SwFlyFrameFormat::SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame ) - : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_FLYFRMFMT ) +SwFlyFrameFormat::SwFlyFrameFormat(SwAttrPool& rPool, const OUString &rFormatName, SwFrameFormat* pDerivedFrame) + : sw::SpzFrameFormat(rPool, rFormatName, pDerivedFrame, RES_FLYFRMFMT) {} SwFlyFrameFormat::~SwFlyFrameFormat() @@ -3014,10 +3006,8 @@ void SwFlyFrameFormat::MakeFrames() if ( pModify == nullptr ) { const SwNode & rNd = *aAnchorAttr.GetAnchorNode(); - SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats(); - for( size_t i = 0; i < rFormats.size(); ++i ) + for(sw::SpzFrameFormat* pFlyFormat: *GetDoc()->GetSpzFrameFormats()) { - SwFrameFormat* pFlyFormat = rFormats[i]; if( pFlyFormat->GetContent().GetContentIdx() && rNd == pFlyFormat->GetContent().GetContentIdx()->GetNode() ) { @@ -3680,25 +3670,24 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc) assert(rAnchor.GetAnchorNode() == pNode); } } - SwFrameFormats const*const pSpzFrameFormats(rDoc.GetSpzFrameFormats()); - if (!pSpzFrameFormats) + if(!rDoc.GetSpzFrameFormats()) return; - for (auto it = pSpzFrameFormats->begin(); it != pSpzFrameFormats->end(); ++it) + for(sw::SpzFrameFormat* pSpz: *rDoc.GetSpzFrameFormats()) { - SwFormatAnchor const& rAnchor((**it).GetAnchor(false)); + SwFormatAnchor const& rAnchor(pSpz->GetAnchor(false)); if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) { assert(!rAnchor.GetAnchorNode() // for invalid documents that lack text:anchor-page-number // it may have an anchor before MakeFrames() is called - || (!SwIterator<SwFrame, SwFrameFormat>(**it).First())); + || (!SwIterator<SwFrame, SwFrameFormat>(*pSpz).First())); } else { SwNode & rNode(*rAnchor.GetAnchorNode()); std::vector<SwFrameFormat*> const& rFlys(rNode.GetAnchoredFlys()); - assert(std::find(rFlys.begin(), rFlys.end(), *it) != rFlys.end()); + assert(std::find(rFlys.begin(), rFlys.end(), pSpz) != rFlys.end()); switch (rAnchor.GetAnchorId()) { case RndStdIds::FLY_AT_FLY: diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 057ce8adad9e..193478da450e 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -953,11 +953,8 @@ void SwContentNotify::ImplDestroy() // the page is known. Thus, this data can be corrected now. const SwPageFrame *pPage = nullptr; - SwFrameFormats *pTable = rDoc.GetSpzFrameFormats(); - - for ( size_t i = 0; i < pTable->size(); ++i ) + for(sw::SpzFrameFormat* pFormat: *rDoc.GetSpzFrameFormats()) { - SwFrameFormat *pFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( RndStdIds::FLY_AT_PAGE != rAnch.GetAnchorId() || rAnch.GetAnchorNode() == nullptr ) @@ -1228,7 +1225,7 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode, } } -void AppendObjsOfNode(SwFrameFormats const*const pTable, SwNodeOffset const nIndex, +void AppendObjsOfNode(sw::FrameFormats<sw::SpzFrameFormat*> const*const pTable, SwNodeOffset const nIndex, SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc, std::vector<sw::Extent>::const_iterator const*const pIter, std::vector<sw::Extent>::const_iterator const*const pEnd, @@ -1236,9 +1233,8 @@ void AppendObjsOfNode(SwFrameFormats const*const pTable, SwNodeOffset const nInd { #if OSL_DEBUG_LEVEL > 0 std::vector<SwFrameFormat*> checkFormats; - for ( size_t i = 0; i < pTable->size(); ++i ) + for(auto pFormat: *pTable) { - SwFrameFormat *pFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( rAnch.GetAnchorNode() && IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode)) @@ -1275,7 +1271,7 @@ void AppendObjsOfNode(SwFrameFormats const*const pTable, SwNodeOffset const nInd } -void AppendObjs(const SwFrameFormats *const pTable, SwNodeOffset const nIndex, +void AppendObjs(const sw::FrameFormats<sw::SpzFrameFormat*> *const pTable, SwNodeOffset const nIndex, SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc) { if (pFrame->IsTextFrame()) @@ -1378,7 +1374,7 @@ bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor return ret; } -void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib) +void AppendAllObjs(const sw::FrameFormats<sw::SpzFrameFormat*>* pTable, const SwFrame* pSib) { //Connecting of all Objects, which are described in the SpzTable with the //layout. @@ -1514,7 +1510,7 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, const bool bStartPercent = bPages && !nEndIndex; SwPageFrame *pPage = pLay->FindPageFrame(); - const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats* pTable = pDoc->GetSpzFrameFormats(); SwFrame *pFrame = nullptr; std::unique_ptr<SwActualSection> pActualSection; std::unique_ptr<SwLayHelper> pPageMaker; @@ -2171,7 +2167,7 @@ void MakeFrames( SwDoc *pDoc, SwNode &rSttIdx, SwNode &rEndIdx ) // depend on value of <bAllowMove> if( !isFlyCreationSuppressed ) { - const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats(); + const sw::SpzFrameFormats* pTable = pDoc->GetSpzFrameFormats(); if( !pTable->empty() ) AppendAllObjs( pTable, pUpper ); } diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 3abc8f20127d..c38201a5ed9d 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -408,14 +408,13 @@ static void lcl_FormatLay( SwLayoutFrame *pLay ) } /// Create Flys or register draw objects -static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage ) +static void lcl_MakeObjs(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, SwPageFrame* pPage) { // formats are in the special table of the document - - for ( size_t i = 0; i < rTable.size(); ++i ) + for(size_t i = 0; i < rSpzs.size(); ++i ) { - SwFrameFormat *pFormat = rTable[i]; - const SwFormatAnchor &rAnch = pFormat->GetAnchor(); + auto pSpz = rSpzs[i]; + const SwFormatAnchor &rAnch = pSpz->GetAnchor(); if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() ) { if( rAnch.GetAnchorNode() ) @@ -424,19 +423,19 @@ static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage ) { SwFormatAnchor aAnch( rAnch ); aAnch.SetAnchor( nullptr ); - pFormat->SetFormatAttr( aAnch ); + pSpz->SetFormatAttr( aAnch ); } else continue; } // is it a border or a SdrObject? - bool bSdrObj = RES_DRAWFRMFMT == pFormat->Which(); + bool bSdrObj = RES_DRAWFRMFMT == pSpz->Which(); SdrObject *pSdrObj = nullptr; - if ( bSdrObj && nullptr == (pSdrObj = pFormat->FindSdrObject()) ) + if ( bSdrObj && nullptr == (pSdrObj = pSpz->FindSdrObject()) ) { OSL_FAIL( "DrawObject not found." ); - pFormat->GetDoc()->DelFrameFormat( pFormat ); + pSpz->GetDoc()->DelFrameFormat( pSpz ); --i; continue; } @@ -469,7 +468,7 @@ static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage ) } else { - SwIterator<SwFlyFrame,SwFormat> aIter( *pFormat ); + SwIterator<SwFlyFrame,SwFormat> aIter( *pSpz ); SwFlyFrame *pFly = aIter.First(); if ( pFly) { @@ -477,7 +476,7 @@ static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage ) pFly->AnchorFrame()->RemoveFly( pFly ); } else - pFly = new SwFlyLayFrame( static_cast<SwFlyFrameFormat*>(pFormat), pPg, pPg ); + pFly = new SwFlyLayFrame( static_cast<SwFlyFrameFormat*>(pSpz), pPg, pPg ); pPg->AppendFly( pFly ); ::RegistFlys( pPg, pFly ); } @@ -1571,17 +1570,17 @@ void SwRootFrame::AssertFlyPages() mbAssertFlyPages = false; SwDoc *pDoc = GetFormat()->GetDoc(); - const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats(); + const sw::SpzFrameFormats* pSpzs = pDoc->GetSpzFrameFormats(); // what page targets the "last" Fly? // note the needed pages in a set sal_uInt16 nMaxPg(0); o3tl::sorted_vector< sal_uInt16 > neededPages; - neededPages.reserve(pTable->size()); + neededPages.reserve(pSpzs->size()); - for ( size_t i = 0; i < pTable->size(); ++i ) + for(auto pSpz: *pSpzs ) { - const SwFormatAnchor &rAnch = (*pTable)[i]->GetAnchor(); + const SwFormatAnchor &rAnch = pSpz->GetAnchor(); if(!rAnch.GetAnchorNode()) { const sal_uInt16 nPageNum(rAnch.GetPageNum()); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 96b048b81fca..6c8fa0ea9f55 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -1261,8 +1261,8 @@ bool SwTabFrame::Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowK pHeadline->InsertBefore( pFoll, nullptr ); SwPageFrame *pPage = pHeadline->FindPageFrame(); - const SwFrameFormats *pTable = GetFormat()->GetDoc()->GetSpzFrameFormats(); - if( !pTable->empty() ) + const sw::SpzFrameFormats* pSpzs = GetFormat()->GetDoc()->GetSpzFrameFormats(); + if( !pSpzs->empty() ) { SwNodeOffset nIndex; SwContentFrame* pFrame = pHeadline->ContainsContent(); @@ -1273,7 +1273,7 @@ bool SwTabFrame::Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowK nIndex = pFrame->IsTextFrame() ? static_cast<SwTextFrame*>(pFrame)->GetTextNodeFirst()->GetIndex() : static_cast<SwNoTextFrame*>(pFrame)->GetNode()->GetIndex(); - AppendObjs( pTable, nIndex, pFrame, pPage, GetFormat()->GetDoc()); + AppendObjs(pSpzs, nIndex, pFrame, pPage, GetFormat()->GetDoc()); pFrame = pFrame->GetNextContentFrame(); if( !pHeadline->IsAnLower( pFrame ) ) break; diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 971918632752..233e973ed178 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -4270,7 +4270,7 @@ void SwRootFrame::InvalidateAllObjPos() static void AddRemoveFlysForNode( SwTextFrame & rFrame, SwTextNode & rTextNode, std::set<SwNodeOffset> *const pSkipped, - const SwFrameFormats & rTable, + const sw::FrameFormats<sw::SpzFrameFormat*>& rTable, SwPageFrame *const pPage, SwTextNode const*const pNode, std::vector<sw::Extent>::const_iterator const& rIterFirst, @@ -4321,7 +4321,7 @@ void AddRemoveFlysAnchoredToFrameStartingAtNode( && rTextNode.GetIndex() <= pMerged->pLastNode->GetIndex()); // add visible flys in non-first node to merged frame // (hidden flys remain and are deleted via DelFrames()) - SwFrameFormats& rTable(*rTextNode.GetDoc().GetSpzFrameFormats()); + sw::SpzFrameFormats& rTable(*rTextNode.GetDoc().GetSpzFrameFormats()); SwPageFrame *const pPage(rFrame.FindPageFrame()); std::vector<sw::Extent>::const_iterator iterFirst(pMerged->extents.begin()); std::vector<sw::Extent>::const_iterator iter(iterFirst); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index a0a1ad028f77..7e39716cd252 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1927,11 +1927,8 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() // HYPERLINKS (Graphics, Frames, OLEs ) - SwFrameFormats* pTable = pDoc->GetSpzFrameFormats(); - const size_t nSpzFrameFormatsCount = pTable->size(); - for( size_t n = 0; n < nSpzFrameFormatsCount; ++n ) + for(sw::SpzFrameFormat* pFrameFormat: *pDoc->GetSpzFrameFormats()) { - SwFrameFormat* pFrameFormat = (*pTable)[n]; const SwFormatURL* pItem; if ( RES_DRAWFRMFMT != pFrameFormat->Which() && GetFrameOfModify(mrSh.GetLayout(), *pFrameFormat, SwFrameType::Fly) && diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index f055f735a94f..61fb23368fbe 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -1043,11 +1043,11 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong aNodeArgs.m_nRightDiff = 0; if( nIndex ) { - SwFrameFormats* pTmp = const_cast<SwFrameFormats*>(GetDoc().GetSpzFrameFormats()); - if( pTmp ) + sw::SpzFrameFormats* pSpzs = const_cast<sw::SpzFrameFormats*>(GetDoc().GetSpzFrameFormats()); + if(pSpzs) { aNodeArgs.m_nIndex = nIndex; - for( SwFrameFormat *pFormat : *pTmp ) + for(auto pFormat: *pSpzs) lcl_MinMaxNode(pFormat, aNodeArgs); } } diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 642e2ed77d62..d17c08e4795b 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -921,9 +921,9 @@ void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool ) } } -SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrameFormat& rFormat ) +SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor(sw::SpzFrameFormat& rFormat) : SwHistoryHint( HSTRY_CHGFLYANCHOR ) - , m_rFormat( rFormat ) + , m_rFormat(rFormat) , m_nOldNodeIndex( rFormat.GetAnchor().GetAnchorNode()->GetIndex() ) , m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == rFormat.GetAnchor().GetAnchorId()) ? rFormat.GetAnchor().GetAnchorContentOffset() @@ -935,6 +935,8 @@ void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) { ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); + // One would expect m_rFormat to only contain FlyFormats, given the name of + // this class, but apparently it is also used for DrawFormats. if (!pDoc->GetSpzFrameFormats()->IsAlive(&m_rFormat)) // Format does still exist return; @@ -1139,9 +1141,9 @@ void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOth m_SwpHstry.push_back( std::move(pHt) ); } -void SwHistory::AddChangeFlyAnchor(SwFrameFormat& rFormat) +void SwHistory::AddChangeFlyAnchor(sw::SpzFrameFormat& rFormat) { - std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeFlyAnchor( rFormat )); + std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeFlyAnchor(rFormat)); m_SwpHstry.push_back( std::move(pHt) ); } diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index d09e1ec6d210..cd1b3b1d9182 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -54,17 +54,16 @@ ( == AUTO ), if the anchor frame has be moved via MoveNodes(..) and DelFrames(..) */ -static void lcl_MakeAutoFrames( const SwFrameFormats& rSpzArr, SwNodeOffset nMovedIndex ) +static void lcl_MakeAutoFrames(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, SwNodeOffset nMovedIndex ) { - for( size_t n = 0; n < rSpzArr.size(); ++n ) + for(auto pSpz: rSpzs) { - SwFrameFormat * pFormat = rSpzArr[n]; - const SwFormatAnchor* pAnchor = &pFormat->GetAnchor(); + const SwFormatAnchor* pAnchor = &pSpz->GetAnchor(); if (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_CHAR) { const SwNode* pAnchorNode = pAnchor->GetAnchorNode(); if( pAnchorNode && nMovedIndex == pAnchorNode->GetIndex() ) - pFormat->MakeFrames(); + pSpz->MakeFrames(); } } } @@ -817,25 +816,20 @@ SwRewriter SwUndoDelete::GetRewriter() const } // Every object, anchored "AtContent" will be reanchored at rPos -static void lcl_ReAnchorAtContentFlyFrames( const SwFrameFormats& rSpzArr, const SwPosition &rPos, SwNodeOffset nOldIdx ) +static void lcl_ReAnchorAtContentFlyFrames(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, const SwPosition &rPos, SwNodeOffset nOldIdx ) { - if( rSpzArr.empty() ) - return; - - SwFrameFormat* pFormat; const SwFormatAnchor* pAnchor; - for( size_t n = 0; n < rSpzArr.size(); ++n ) + for(auto pSpz: rSpzs) { - pFormat = rSpzArr[n]; - pAnchor = &pFormat->GetAnchor(); + pAnchor = &pSpz->GetAnchor(); if (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_PARA) { - SwNode* pAnchorNode = pAnchor->GetAnchorNode(); + SwNode* pAnchorNode = pAnchor->GetAnchorNode(); if( pAnchorNode && nOldIdx == pAnchorNode->GetIndex() ) { SwFormatAnchor aAnch( *pAnchor ); aAnch.SetAnchor( &rPos ); - pFormat->SetFormatAttr( aAnch ); + pSpz->SetFormatAttr( aAnch ); } } } diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index e1fa8570f054..523d065989f4 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -976,10 +976,10 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, if( DelContentType::Fly & nDelContentType ) { sal_uInt16 nChainInsPos = m_pHistory ? m_pHistory->Count() : 0; - const SwFrameFormats& rSpzArr = *rDoc.GetSpzFrameFormats(); + const sw::SpzFrameFormats& rSpzArr = *rDoc.GetSpzFrameFormats(); if( !rSpzArr.empty() ) { - SwFrameFormat* pFormat; + sw::SpzFrameFormat* pFormat; const SwFormatAnchor* pAnchor; size_t n = rSpzArr.size(); const SwPosition* pAPos; diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 232af5876c5d..6db3d9315114 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -100,8 +100,8 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame) SwDoc *const pDoc = & rContext.GetDoc(); // add again into array - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); - rFlyFormats.push_back( m_pFrameFormat ); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + rFlyFormats.push_back( static_cast<sw::SpzFrameFormat*>(m_pFrameFormat)); // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page if ( RES_DRAWFRMFMT == m_pFrameFormat->Which() ) @@ -272,8 +272,8 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) m_pFrameFormat->ResetFormatAttr( RES_ANCHOR ); // delete anchor // delete from array - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); - rFlyFormats.erase( m_pFrameFormat ); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + rFlyFormats.erase(static_cast<sw::SpzFrameFormat*>(m_pFrameFormat)); } SwUndoInsLayFormat::SwUndoInsLayFormat( SwFrameFormat* pFormat, SwNodeOffset nNodeIdx, sal_Int32 nCntIdx ) diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index cfdae61e84ab..3fd7fa8ce244 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -219,7 +219,7 @@ void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &) // remove from array SwDoc* pDoc = pFormat->GetDoc(); - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); for( sal_uInt16 n = 1; n < m_nSize; ++n ) @@ -227,7 +227,7 @@ void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &) SwUndoGroupObjImpl& rSave = m_pObjArray[n]; ::lcl_RestoreAnchor( rSave.pFormat, rSave.nNodeIdx ); - rFlyFormats.push_back( rSave.pFormat ); + rFlyFormats.push_back(static_cast<sw::SpzFrameFormat*>(rSave.pFormat)); pObj = rSave.pObj; @@ -264,7 +264,7 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) // remove from array SwDoc* pDoc = m_pObjArray[0].pFormat->GetDoc(); - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); // This will store the textboxes from the ex-group-shapes std::vector<std::pair<SdrObject*, SwFrameFormat*>> vTextBoxes; @@ -297,7 +297,7 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) // re-insert group object ::lcl_RestoreAnchor( m_pObjArray[0].pFormat, m_pObjArray[0].nNodeIdx ); - rFlyFormats.push_back( m_pObjArray[0].pFormat ); + rFlyFormats.push_back(static_cast<sw::SpzFrameFormat*>(m_pObjArray[0].pFormat )); SwDrawContact *pContact = new SwDrawContact( m_pObjArray[0].pFormat, m_pObjArray[0].pObj ); // #i26791# - correction: connect object to layout @@ -336,7 +336,7 @@ void SwUndoDrawGroup::AddObj( sal_uInt16 nPos, SwDrawFrameFormat* pFormat, SdrOb pFormat->RemoveAllUnos(); // remove from array - SwFrameFormats& rFlyFormats = *pFormat->GetDoc()->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pFormat->GetDoc()->GetSpzFrameFormats(); rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); } @@ -367,7 +367,7 @@ SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj, const SwDoc& rDoc ) pFormat->RemoveAllUnos(); // remove from array - SwFrameFormats& rFlyFormats = *pFormat->GetDoc()->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pFormat->GetDoc()->GetSpzFrameFormats(); rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); } @@ -388,7 +388,7 @@ void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) m_bDeleteFormat = true; SwDoc *const pDoc = & rContext.GetDoc(); - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); // This will store the textboxes what were owned by this group std::vector<std::pair<SdrObject*, SwFrameFormat*>> vTextBoxes; @@ -424,7 +424,7 @@ void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) // re-insert group object ::lcl_RestoreAnchor( m_pObjArray[0].pFormat, m_pObjArray[0].nNodeIdx ); - rFlyFormats.push_back( m_pObjArray[0].pFormat ); + rFlyFormats.push_back(static_cast<sw::SpzFrameFormat*>(m_pObjArray[0].pFormat )); SwDrawContact *pContact = new SwDrawContact( m_pObjArray[0].pFormat, m_pObjArray[0].pObj ); pContact->ConnectToLayout(); @@ -481,7 +481,7 @@ void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &) // remove from array SwDoc* pDoc = pFormat->GetDoc(); - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); for( sal_uInt16 n = 1; n < m_nSize; ++n ) @@ -489,7 +489,7 @@ void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &) SwUndoGroupObjImpl& rSave = m_pObjArray[n]; ::lcl_RestoreAnchor( rSave.pFormat, rSave.nNodeIdx ); - rFlyFormats.push_back( rSave.pFormat ); + rFlyFormats.push_back(static_cast<sw::SpzFrameFormat*>(rSave.pFormat)); SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat; @@ -588,12 +588,12 @@ SwUndoDrawDelete::~SwUndoDrawDelete() void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) { m_bDeleteFormat = false; - SwFrameFormats & rFlyFormats = *rContext.GetDoc().GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *rContext.GetDoc().GetSpzFrameFormats(); for( size_t n = 0; n < m_pMarkList->GetMarkCount(); ++n ) { SwUndoGroupObjImpl& rSave = m_pObjArray[n]; ::lcl_RestoreAnchor( rSave.pFormat, rSave.nNodeIdx ); - rFlyFormats.push_back( rSave.pFormat ); + rFlyFormats.push_back(static_cast<sw::SpzFrameFormat*>(rSave.pFormat)); SdrObject *pObj = rSave.pObj; SwDrawContact *pContact = new SwDrawContact( rSave.pFormat, pObj ); pContact->Changed_( *pObj, SdrUserCallType::Inserted, nullptr ); @@ -619,7 +619,7 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext) { m_bDeleteFormat = true; - SwFrameFormats & rFlyFormats = *rContext.GetDoc().GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *rContext.GetDoc().GetSpzFrameFormats(); for( size_t n = 0; n < m_pMarkList->GetMarkCount(); ++n ) { SwUndoGroupObjImpl& rSave = m_pObjArray[n]; @@ -650,7 +650,7 @@ void SwUndoDrawDelete::AddObj( SwDrawFrameFormat* pFormat, // remove from array SwDoc* pDoc = pFormat->GetDoc(); - SwFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); + sw::SpzFrameFormats& rFlyFormats = *pDoc->GetSpzFrameFormats(); rFlyFormats.erase( std::find( rFlyFormats.begin(), rFlyFormats.end(), pFormat )); m_pMarkList->InsertEntry( rMark ); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index fffd8e8b4e51..8c351559db69 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -434,10 +434,8 @@ SwUndoTableToText::SwUndoTableToText( const SwTable& rTable, sal_Unicode cCh ) const SwTableNode* pTableNd = rTable.GetTableNode(); SwNodeOffset nTableStt = pTableNd->GetIndex(), nTableEnd = pTableNd->EndOfSectionIndex(); - const SwFrameFormats& rFrameFormatTable = *pTableNd->GetDoc().GetSpzFrameFormats(); - for( size_t n = 0; n < rFrameFormatTable.size(); ++n ) + for(sw::SpzFrameFormat* pFormat: *pTableNd->GetDoc().GetSpzFrameFormats()) { - SwFrameFormat* pFormat = rFrameFormatTable[ n ]; SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 627ab4bf870c..65e70846470f 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1079,17 +1079,9 @@ template<FlyCntType T> SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc& rDoc) { SolarMutexGuard aGuard; - const SwFrameFormats* const pFormats = rDoc.GetSpzFrameFormats(); - if (pFormats->empty()) - return; - // #i104937# - const size_t nSize = pFormats->size(); - // #i104937# - SwFrameFormat* pFormat( nullptr ); - for( size_t i = 0; i < nSize; ++i ) + for(sw::SpzFrameFormat* pFormat: *rDoc.GetSpzFrameFormats()) { // #i104937# - pFormat = (*pFormats)[i]; if(pFormat->Which() != RES_FLYFRMFMT || SwTextBoxHelper::isTextBox(pFormat, RES_FLYFRMFMT)) continue; const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index c73c2c34a458..c07c78237e92 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -155,12 +155,9 @@ void CollectFrameAtNode( const SwNode& rNd, } else { - const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); - const size_t nSize = rFormats.size(); - for ( size_t i = 0; i < nSize; i++) + for(sw::SpzFrameFormat* pSpz: *rDoc.GetSpzFrameFormats()) { - const SwFrameFormat* pFormat = rFormats[ i ]; - const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); + const SwFormatAnchor& rAnchor = pSpz->GetAnchor(); const SwNode* pAnchorNode; if( rAnchor.GetAnchorId() == nChkType && nullptr != (pAnchorNode = rAnchor.GetAnchorNode()) && @@ -172,7 +169,7 @@ void CollectFrameAtNode( const SwNode& rNd, const sal_Int32 nIndex = rAnchor.GetAnchorContentOffset(); sal_uInt32 nOrder = rAnchor.GetOrder(); - rFrames.emplace_back(nIndex, nOrder, std::make_unique<sw::FrameClient>(const_cast<SwFrameFormat*>(pFormat))); + rFrames.emplace_back(nIndex, nOrder, std::make_unique<sw::FrameClient>(pSpz)); } } std::sort(rFrames.begin(), rFrames.end(), FrameClientSortListLess()); diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 18d0769cd3b4..a6197e994c51 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -728,15 +728,8 @@ void SwViewShell::UpdateFields(bool bCloseDB) void SwViewShell::UpdateOleObjectPreviews() { SwDoc* pDoc = GetDoc(); - const SwFrameFormats* const pFormats = pDoc->GetSpzFrameFormats(); - if (pFormats->empty()) + for(sw::SpzFrameFormat* pFormat: *pDoc->GetSpzFrameFormats()) { - return; - } - - for (size_t i = 0; i < pFormats->size(); ++i) - { - SwFrameFormat* pFormat = (*pFormats)[i]; if (pFormat->Which() != RES_FLYFRMFMT) { continue; diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 67c213c4d331..741ceff97c33 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -1318,20 +1318,18 @@ void SwHTMLWriter::GetControls() } // and now the ones in a character-bound frame - const SwFrameFormats* pSpzFrameFormats = m_pDoc->GetSpzFrameFormats(); - for( size_t i=0; i<pSpzFrameFormats->size(); i++ ) + for(sw::SpzFrameFormat* pSpz: *m_pDoc->GetSpzFrameFormats()) { - const SwFrameFormat *pFrameFormat = (*pSpzFrameFormats)[i]; - if( RES_DRAWFRMFMT != pFrameFormat->Which() ) + if( RES_DRAWFRMFMT != pSpz->Which() ) continue; - const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor(); + const SwFormatAnchor& rAnchor = pSpz->GetAnchor(); const SwNode *pAnchorNode = rAnchor.GetAnchorNode(); if ((RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pAnchorNode) continue; const SdrObject *pSdrObj = - SwHTMLWriter::GetHTMLControl( *static_cast<const SwDrawFrameFormat*>(pFrameFormat) ); + SwHTMLWriter::GetHTMLControl(*static_cast<SwDrawFrameFormat*>(pSpz) ); if( !pSdrObj ) continue; diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index daf90faff773..f8f6c8ba31a8 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -1456,11 +1456,10 @@ void SwHTMLParser::StripTrailingPara() if( pCNd && pCNd->StartOfSectionIndex() + 2 < pCNd->EndOfSectionIndex() && CanRemoveNode(nNodeIdx)) { - const SwFrameFormats& rFrameFormatTable = *m_xDoc->GetSpzFrameFormats(); - for( auto pFormat : rFrameFormatTable ) + for(sw::SpzFrameFormat* pSpz: *m_xDoc->GetSpzFrameFormats()) { - SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); + SwFormatAnchor const*const pAnchor = &pSpz->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) || diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 67502f1a278b..49e3e9a8abce 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -4551,12 +4551,10 @@ bool SwHTMLParser::HasCurrentParaFlys( bool bNoSurroundOnly, { SwNode& rNode = m_pPam->GetPoint()->GetNode(); - const SwFrameFormats& rFrameFormatTable = *m_xDoc->GetSpzFrameFormats(); bool bFound = false; - for ( size_t i=0; i<rFrameFormatTable.size(); i++ ) + for(sw::SpzFrameFormat* pFormat: *m_xDoc->GetSpzFrameFormats()) { - const SwFrameFormat *const pFormat = rFrameFormatTable[i]; SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); // A frame was found, when // - it is paragraph-bound, and diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 66b4aa8fe450..ba9425ec3c2b 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -953,7 +953,7 @@ sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrameFormat& rFormat ) const // no Layout for this format, then recalc the ordnum SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(&rFormat); nOrdNum = std::distance(m_rDoc.GetSpzFrameFormats()->begin(), - m_rDoc.GetSpzFrameFormats()->find( pFormat ) ); + m_rDoc.GetSpzFrameFormats()->find(static_cast<sw::SpzFrameFormat*>(pFormat))); const SwDrawModel* pModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel(); if( pModel ) |