diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 10 | ||||
-rw-r--r-- | sw/inc/docary.hxx | 1 | ||||
-rw-r--r-- | sw/inc/frameformats.hxx | 200 | ||||
-rw-r--r-- | sw/inc/frmfmt.hxx | 6 | ||||
-rw-r--r-- | sw/inc/swtblfmt.hxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout3.cxx | 2 | ||||
-rw-r--r-- | sw/qa/filter/html/html.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docchart.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/docnode/ndcopy.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/edit/edglss.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/fields/cellfml.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/undo/unattr.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 17 |
21 files changed, 258 insertions, 56 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index df07fbae0043..1296fbaa866d 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -34,6 +34,7 @@ #include <editeng/numitem.hxx> #include "tox.hxx" #include "frmfmt.hxx" +#include "frameformats.hxx" #include "charfmt.hxx" #include "docary.hxx" #include "charformats.hxx" @@ -163,6 +164,7 @@ namespace sw { class DocumentLayoutManager; class DocumentStylePoolManager; class DocumentExternalDataManager; + template<class T> class FrameFormats; class GrammarContact; class OnlineAccessibilityCheck; } @@ -248,7 +250,7 @@ class SW_DLLPUBLIC SwDoc final std::unique_ptr<SwCharFormats> mpCharFormatTable; std::unique_ptr<SwFrameFormats> mpSpzFrameFormatTable; std::unique_ptr<SwSectionFormats> mpSectionFormatTable; - std::unique_ptr<SwFrameFormats> mpTableFrameFormatTable; //< For tables + std::unique_ptr<sw::TableFrameFormats> mpTableFrameFormatTable; //< For tables std::unique_ptr<SwTextFormatColls> mpTextFormatCollTable; //< FormatCollections std::unique_ptr<SwGrfFormatColls> mpGrfFormatCollTable; @@ -819,10 +821,10 @@ public: SwGrfFormatColl *pDerivedFrom); // Table formatting - const SwFrameFormats* GetTableFrameFormats() const { return mpTableFrameFormatTable.get(); } - SwFrameFormats* GetTableFrameFormats() { return mpTableFrameFormatTable.get(); } + const sw::TableFrameFormats* GetTableFrameFormats() const { return mpTableFrameFormatTable.get(); } + sw::TableFrameFormats* GetTableFrameFormats() { return mpTableFrameFormatTable.get(); } size_t GetTableFrameFormatCount( bool bUsed ) const; - SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const; + SwTableFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const; SwTableFormat* MakeTableFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom); void DelTableFrameFormat( SwTableFormat* pFormat ); SwTableFormat* FindTableFormatByName( const OUString& rName, bool bAll = false ) const; diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 98c84cbbd270..64f251957a06 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -49,6 +49,7 @@ public: // default linear search implementation, some subclasses will override with a more efficient search virtual SwFormat* FindFormatByName(const OUString& rName) const; + virtual void Rename(const SwFrameFormat&, const OUString&) {}; SwFormatsBase() = default; SwFormatsBase(SwFormatsBase const &) = default; diff --git a/sw/inc/frameformats.hxx b/sw/inc/frameformats.hxx index 4e06efe44b04..97c86408e867 100644 --- a/sw/inc/frameformats.hxx +++ b/sw/inc/frameformats.hxx @@ -19,12 +19,17 @@ #pragma once #include "docary.hxx" +#include "swtblfmt.hxx" #include <boost/multi_index_container.hpp> #include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/identity.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/random_access_index.hpp> +#include <boost/multi_index/tag.hpp> + +class SwFrameFormat; +class SwTableFormat; // Like o3tl::find_partialorder_ptrequals // We don't allow duplicated object entries! @@ -102,6 +107,7 @@ public: virtual size_t GetFormatCount() const override { return m_Array.size(); } virtual SwFormat* GetFormat(size_t idx) const override { return operator[](idx); } + virtual void Rename(const SwFrameFormat& rFormat, const OUString& sNewName) override; /// fast check if given format is contained here /// @precond pFormat must not have been deleted @@ -118,4 +124,198 @@ public: virtual SwFrameFormat* FindFormatByName(const OUString& rName) const override; }; +namespace sw +{ +template <class value_type> class FrameFormats final : public SwFormatsBase +{ + struct ByPos + { + }; + struct ByTypeAndName + { + }; + struct FrameFormatsKey + : boost::multi_index::composite_key< + value_type, + boost::multi_index::const_mem_fun<SwFormat, const OUString&, &SwFormat::GetName>, + boost::multi_index::const_mem_fun<SwFormat, sal_uInt16, &SwFormat::Which>, + boost::multi_index::identity<value_type> // the actual object pointer + > + { + }; + typedef boost::multi_index_container< + value_type, boost::multi_index::indexed_by< + boost::multi_index::random_access<boost::multi_index::tag<ByPos>>, + boost::multi_index::ordered_unique<boost::multi_index::tag<ByTypeAndName>, + FrameFormatsKey>>> + FrameFormatsContainer; + // function updating ByName index via modify + friend class ::SwFrameFormat; + +public: + typedef typename FrameFormatsContainer::size_type size_type; + typedef typename FrameFormatsContainer::template index<ByPos>::type index_type; + typedef typename index_type::iterator iterator; + typedef typename index_type::const_iterator const_iterator; + typedef typename FrameFormatsContainer::template index<ByTypeAndName>::type name_index_type; + typedef typename name_index_type::iterator name_iterator; + typedef typename name_index_type::const_iterator const_name_iterator; + typedef typename std::pair<const_name_iterator, const_name_iterator> range_type; + +private: + FrameFormatsContainer m_vContainer; + index_type& GetByPos() { return m_vContainer.template get<ByPos>(); } + name_index_type& GetByTypeAndName() { return m_vContainer.template get<ByTypeAndName>(); } + const index_type& GetByPos() const { return m_vContainer.template get<ByPos>(); } + const name_index_type& GetByTypeAndName() const + { + return m_vContainer.template get<ByTypeAndName>(); + } + +public: + FrameFormats(){}; + // frees all SwFrameFormat! + virtual ~FrameFormats() override { DeleteAndDestroyAll(); }; + + bool empty() const { return m_vContainer.empty(); } + size_t size() const { return m_vContainer.size(); } + + // Only fails, if you try to insert the same object twice + std::pair<const_iterator, bool> push_back(const value_type& x) + { + SAL_WARN_IF(x->m_ffList != nullptr, "sw.core", "Inserting already assigned item"); + assert(x->m_ffList == nullptr); + x->m_ffList = this; + return GetByPos().push_back(const_cast<value_type>(x)); + }; + + // This will try to remove the exact object! + bool erase(const value_type& x) + { + const_iterator const ret = find(x); + SAL_WARN_IF(x->m_ffList != this, "sw.core", "Removing invalid / unassigned item"); + if (ret != end()) + { + assert(x == *ret); + x->m_ffList = nullptr; + GetByPos().erase(ret); + return true; + } + return false; + }; + void erase(size_type index) { erase(begin() + index); }; + void erase(const_iterator const& position) + { + (*position)->m_ffList = nullptr; + GetByPos().erase(begin() + (position - begin())); + } + + // Get the iterator of the exact object (includes pointer!), + // e.g for position with std::distance. + // There is also ContainsFormat, if you don't need the position. + const_iterator find(const value_type& x) const + { + auto it = GetByTypeAndName().find(std::make_tuple(x->GetName(), x->Which(), x)); + return m_vContainer.template project<ByPos>(it); + }; + + const_name_iterator findByTypeAndName(sal_uInt16 type, const OUString& name) const + { + return GetByTypeAndName().find(std::make_tuple(name, type)); + }; + // search for formats by name + range_type findRangeByName(const OUString& rName) const + { + auto& idx = GetByTypeAndName(); + auto it = idx.lower_bound(std::make_tuple(rName, sal_uInt16(0))); + auto itEnd = idx.upper_bound(std::make_tuple(rName, SAL_MAX_UINT16)); + return { it, itEnd }; + }; + // So we can actually check for end() + const_name_iterator typeAndNameEnd() const { return GetByTypeAndName().end(); } + + const value_type& operator[](size_t index) const { return GetByPos().operator[](index); } + const value_type& front() const { return GetByPos().front(); } + const value_type& back() const { return GetByPos().back(); } + const_iterator begin() const { return GetByPos().begin(); } + const_iterator end() const { return GetByPos().end(); } + + void dumpAsXml(xmlTextWriterPtr pWriter, const char*) const + { + // TODO + //(void)xmlTextWriterStartElement(pWriter, BAD_CAST(pName)); + for (const auto pFormat : GetByPos()) + pFormat->dumpAsXml(pWriter); + //(void)xmlTextWriterEndElement(pWriter); + }; + + virtual size_t GetFormatCount() const override { return m_vContainer.size(); } + virtual SwFormat* GetFormat(size_t idx) const override + { + return const_cast<value_type&>(operator[](idx)); + }; + virtual void Rename(const SwFrameFormat& rFormat, const OUString& sNewName) override + { + assert(dynamic_cast<value_type>(const_cast<SwFrameFormat*>(&rFormat))); + iterator it = find(static_cast<value_type>(const_cast<SwFrameFormat*>(&rFormat))); + assert(end() != it); + const auto sOldName = rFormat.GetName(); + auto fRenamer + = [sNewName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sNewName, false); }; + auto fRenamerUndo + = [sOldName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sOldName, false); }; + bool const renamed = GetByPos().modify(it, fRenamer, fRenamerUndo); + assert(renamed); + (void)renamed; // unused in NDEBUG + }; + + /// fast check if given format is contained here + /// @precond pFormat must not have been deleted + 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(); }; + + void DeleteAndDestroyAll(bool keepDefault = false) + { + if (empty()) + return; + const int offset = keepDefault ? 1 : 0; + for (const_iterator it = begin() + offset; it != end(); ++it) + delete *it; + if (offset) + GetByPos().erase(begin() + offset, end()); + else + m_vContainer.clear(); + }; + + bool newDefault(const value_type& x) + { + std::pair<iterator, bool> res = GetByPos().push_front(const_cast<value_type&>(x)); + if (!res.second) + newDefault(res.first); + return res.second; + }; + void newDefault(const_iterator const& position) + { + if (position == begin()) + return; + GetByPos().relocate(begin(), position); + }; + + // Override return type to reduce casting + value_type FindFrameFormatByName(const OUString& rName) const + { + auto& idx = GetByTypeAndName(); + auto it = idx.lower_bound(std::make_tuple(rName, sal_uInt16(0))); + if (it != idx.end() && (*it)->GetName() == rName) + return *it; + return nullptr; + }; +}; +typedef FrameFormats<::SwTableFormat*> TableFrameFormats; +} + +template class SW_DLLPUBLIC sw::FrameFormats<SwTableFormat*>; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index ec67847247f8..f5e44e03136c 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -53,8 +53,11 @@ namespace sw : SfxHint(SfxHintId::SwFindSdrObject), m_rpObject(rpObject) {}; virtual ~FindSdrObjectHint() override; }; + template<class T> class FrameFormats; } +class SwFormatsBase; class SwFrameFormats; +class SwTableFormat; /// Style of a layout element. class SW_DLLPUBLIC SwFrameFormat @@ -64,6 +67,7 @@ class SW_DLLPUBLIC SwFrameFormat friend class SwPageDesc; ///< Is allowed to call protected CTor. 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 SwTextBoxHelper; friend class SwUndoFlyBase; ///< calls SetOtherTextBoxFormat @@ -73,7 +77,7 @@ class SW_DLLPUBLIC SwFrameFormat drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes; // The assigned SwFrmFmt list. - SwFrameFormats *m_ffList; + SwFormatsBase* m_ffList; std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats; diff --git a/sw/inc/swtblfmt.hxx b/sw/inc/swtblfmt.hxx index de72adcfee6e..d951196728ac 100644 --- a/sw/inc/swtblfmt.hxx +++ b/sw/inc/swtblfmt.hxx @@ -19,11 +19,12 @@ #ifndef INCLUDED_SW_INC_SWTBLFMT_HXX #define INCLUDED_SW_INC_SWTBLFMT_HXX +#include "swdllapi.h" #include "frmfmt.hxx" #include <tools/solar.h> -class SAL_DLLPUBLIC_RTTI SwTableFormat final : public SwFrameFormat +class SW_DLLPUBLIC SwTableFormat final : public SwFrameFormat { friend class SwDoc; diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 824e51b4c710..64d9862ea990 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1260,7 +1260,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf128959) "portion", "amet commodo magna eros quis urna."); // Also check that the widow control for the paragraph is not turned off: - SwFrameFormats& rTableFormats = *pDocument->GetTableFrameFormats(); + sw::TableFrameFormats& rTableFormats = *pDocument->GetTableFrameFormats(); SwFrameFormat* pTableFormat = rTableFormats[0]; SwTable* pTable = SwTable::FindTable(pTableFormat); const SwTableBox* pCell = pTable->GetTableBox("A1"); diff --git a/sw/qa/filter/html/html.cxx b/sw/qa/filter/html/html.cxx index 2b0c36508378..6cd714bbdd48 100644 --- a/sw/qa/filter/html/html.cxx +++ b/sw/qa/filter/html/html.cxx @@ -236,7 +236,7 @@ CPPUNIT_TEST_FIXTURE(Test, testCenteredTableCSSImport) // Then make sure that the table is centered: SwDoc* pDoc = getSwDoc(); - const SwFrameFormats& rTableFormats = *pDoc->GetTableFrameFormats(); + const sw::TableFrameFormats& rTableFormats = *pDoc->GetTableFrameFormats(); const SwFrameFormat* pTableFormat = rTableFormats[0]; sal_Int16 eHoriOrient = pTableFormat->GetHoriOrient().GetHoriOrient(); // Without the accompanying fix in place, this test would have failed with: diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx index 70e96968e4df..e421ac9ad02a 100644 --- a/sw/source/core/doc/docchart.cxx +++ b/sw/source/core/doc/docchart.cxx @@ -81,10 +81,8 @@ void SwDoc::DoUpdateAllCharts() if( !pVSh ) return; - const SwFrameFormats& rTableFormats = *GetTableFrameFormats(); - for( size_t n = 0; n < rTableFormats.size(); ++n ) + for(const SwTableFormat* pFormat: *GetTableFrameFormats()) { - const SwFrameFormat* pFormat = rTableFormats[ n ]; if( SwTable* pTmpTable = SwTable::FindTable( pFormat ) ) if( const SwTableNode* pTableNd = pTmpTable->GetTableNode() ) if( pTableNd->GetNodes().IsDocNodes() ) @@ -157,10 +155,8 @@ void SwDoc::SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName bool bNameFound = rNewName.isEmpty(); if( !bNameFound ) { - const SwFrameFormats& rTable = *GetTableFrameFormats(); - for( size_t i = rTable.size(); i; ) + for(const SwTableFormat* pFormat: *GetTableFrameFormats()) { - const SwFrameFormat* pFormat = rTable[ --i ]; if( !pFormat->IsDefault() && pFormat->GetName() == rNewName && IsUsed( *pFormat ) ) { diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index f633dd4985b7..aa737661d6dc 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -736,7 +736,7 @@ void SwDoc::DelFrameFormat( SwFrameFormat *pFormat, bool bBroadcast ) void SwDoc::DelTableFrameFormat( SwTableFormat *pFormat ) { - SwFrameFormats::const_iterator it = mpTableFrameFormatTable->find( pFormat ); + auto it = mpTableFrameFormatTable->find( pFormat ); OSL_ENSURE( it != mpTableFrameFormatTable->end(), "Format not found," ); mpTableFrameFormatTable->erase( it ); delete pFormat; @@ -775,7 +775,7 @@ size_t SwDoc::GetTableFrameFormatCount(bool bUsed) const SwAutoFormatGetDocNode aGetHt(&GetNodes()); size_t nCount = 0; - for (SwFrameFormat* const & pFormat : *mpTableFrameFormatTable) + for (const SwTableFormat* pFormat: *mpTableFrameFormatTable) { if (!pFormat->GetInfo(aGetHt)) nCount++; @@ -783,18 +783,18 @@ size_t SwDoc::GetTableFrameFormatCount(bool bUsed) const return nCount; } -SwFrameFormat& SwDoc::GetTableFrameFormat(size_t nFormat, bool bUsed) const +SwTableFormat& SwDoc::GetTableFrameFormat(size_t nFormat, bool bUsed) const { if (!bUsed) { - return *((*mpTableFrameFormatTable)[nFormat]); + return *const_cast<SwTableFormat*>((*mpTableFrameFormatTable)[nFormat]); } SwAutoFormatGetDocNode aGetHt(&GetNodes()); size_t index = 0; - for (SwFrameFormat* const & pFormat : *mpTableFrameFormatTable) + for(SwTableFormat* pFormat: *mpTableFrameFormatTable) { if (!pFormat->GetInfo(aGetHt)) { @@ -2174,4 +2174,15 @@ void SwFrameFormats::newDefault( const_iterator const& position ) m_PosIndex.relocate( begin(), position ); } +void SwFrameFormats::Rename(const SwFrameFormat& rFormat, const OUString& rNewName) +{ + iterator it = find(const_cast<SwFrameFormat*>(&rFormat)); + assert(end() != it); + const auto sOldName = rFormat.GetName(); + auto fRenamer = [rNewName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(rNewName, false); }; + auto fRenamerUndo = [sOldName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sOldName, false); }; + bool const renamed = m_PosIndex.modify(it, fRenamer, fRenamerUndo); + assert(renamed); + (void)renamed; // unused in NDEBUG +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index c36da0c4f6a7..5884616e9ee9 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -236,7 +236,7 @@ SwDoc::SwDoc() mpCharFormatTable( new SwCharFormats ), mpSpzFrameFormatTable( new SwFrameFormats() ), mpSectionFormatTable( new SwSectionFormats ), - mpTableFrameFormatTable( new SwFrameFormats() ), + mpTableFrameFormatTable( new sw::TableFrameFormats() ), mpTextFormatCollTable( new SwTextFormatColls() ), mpGrfFormatCollTable( new SwGrfFormatColls() ), mpTOXTypes( new SwTOXTypes ), diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 0a80b25d2f6b..82051e0be6a8 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1619,9 +1619,8 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode, { SwDoc* pDoc = GetFormat()->GetDoc(); SwNodes& rNds = pDoc->GetNodes(); - const SwFrameFormats& rArr = *pDoc->GetTableFrameFormats(); - for( auto pFrameFormat : rArr ) + for(SwTableFormat* pFrameFormat: *pDoc->GetTableFrameFormats()) { ::SetProgressState( 0, pDoc->GetDocShell() ); diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 1f27421ad618..8a63949fa3c8 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -256,10 +256,10 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc& rDoc, const SwNodeIndex& rIdx ) const OUString sTableName( GetTable().GetFrameFormat()->GetName() ); if( !rDoc.IsCopyIsMove() ) { - const SwFrameFormats& rTableFormats = *rDoc.GetTableFrameFormats(); + const sw::TableFrameFormats& rTableFormats = *rDoc.GetTableFrameFormats(); for( size_t n = rTableFormats.size(); n; ) { - const SwFrameFormat* pFormat = rTableFormats[--n]; + const SwTableFormat* pFormat = rTableFormats[--n]; if (pFormat->GetName() == sTableName && rDoc.IsUsed(*pFormat)) { sTableName = rDoc.GetUniqueTableName(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index d076e616af5c..b9ae26a0e421 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -3875,8 +3875,8 @@ OUString SwDoc::GetUniqueTableName() const for( size_t n = 0; n < mpTableFrameFormatTable->size(); ++n ) { - const SwFrameFormat* pFormat = (*mpTableFrameFormatTable)[ n ]; - if( !pFormat->IsDefault() && IsUsed( *pFormat ) && + const SwTableFormat* pFormat = (*mpTableFrameFormatTable)[ n ]; + if( !pFormat->IsDefault() && IsUsed( *pFormat ) && pFormat->GetName().startsWith( aName ) ) { // Get number and set the Flag @@ -4451,11 +4451,11 @@ void SwDoc::UnProtectTables( const SwPaM& rPam ) bool bChgd = false, bHasSel = rPam.HasMark() || rPam.GetNext() != &rPam; - SwFrameFormats& rFormats = *GetTableFrameFormats(); + sw::TableFrameFormats& rFormats = *GetTableFrameFormats(); SwTable* pTable; const SwTableNode* pTableNd; for( auto n = rFormats.size(); n ; ) - if( nullptr != (pTable = SwTable::FindTable( rFormats[ --n ] )) && + if( nullptr != (pTable = SwTable::FindTable( rFormats[ --n ])) && nullptr != (pTableNd = pTable->GetTableNode() ) && pTableNd->GetNodes().IsDocNodes() ) { diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 4f1f69971f75..667ae4690602 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -179,7 +179,7 @@ bool SwEditShell::CopySelToDoc( SwDoc& rInsDoc ) if( bCpyTableNm ) { const OUString rTableName = pTableNd->GetTable().GetFrameFormat()->GetName(); - const SwFrameFormats& rTableFormats = *rInsDoc.GetTableFrameFormats(); + const sw::TableFrameFormats& rTableFormats = *rInsDoc.GetTableFrameFormats(); for( auto n = rTableFormats.size(); n; ) if( rTableFormats[ --n ]->GetName() == rTableName ) { diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index e215672febe6..7c8179f672cb 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -748,11 +748,11 @@ OUString SwTableFormula::ScanString( FnScanFormula fnFormula, const SwTable& rTa const SwTable* SwTableFormula::FindTable( SwDoc& rDoc, std::u16string_view rNm ) { - const SwFrameFormats& rTableFormats = *rDoc.GetTableFrameFormats(); + const sw::TableFrameFormats& rTableFormats = *rDoc.GetTableFrameFormats(); const SwTable* pTmpTable = nullptr, *pRet = nullptr; for( auto nFormatCnt = rTableFormats.size(); nFormatCnt; ) { - SwFrameFormat* pFormat = rTableFormats[ --nFormatCnt ]; + SwTableFormat* pFormat = rTableFormats[ --nFormatCnt ]; // if we are called from Sw3Writer, a number is dependent on the format name SwTableBox* pFBox; if ( rNm == o3tl::getToken(pFormat->GetName(), 0, 0x0a) && diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 649f31c9807e..b0f07c59f62b 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2608,17 +2608,9 @@ SwFrameFormat::~SwFrameFormat() void SwFrameFormat::SetFormatName( const OUString& rNewName, bool bBroadcast ) { if (m_ffList != nullptr) { - SwFrameFormats::iterator it = m_ffList->find( this ); - assert( m_ffList->end() != it ); SAL_INFO_IF(m_aFormatName == rNewName, "sw.core", "SwFrmFmt not really renamed, as both names are equal"); - - // As it's a non-unique list, rename should never fail! sw::NameChanged aHint(m_aFormatName, rNewName); - bool const renamed = - m_ffList->m_PosIndex.modify( it, - change_name( rNewName ), change_name( m_aFormatName ) ); - assert(renamed); - (void)renamed; // unused in NDEBUG + m_ffList->Rename(*this, rNewName); if (bBroadcast) { GetNotifier().Broadcast(aHint); } diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 2c07bda259f0..ef729671d936 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -155,7 +155,8 @@ void SwUndoFormatAttr::Init( const SwFormat & rFormat ) SaveFlyAnchor( &rFormat, m_bSaveDrawPt ); } else if ( RES_FRMFMT == m_nFormatWhich ) { const SwDoc* pDoc = rFormat.GetDoc(); - if (pDoc->GetTableFrameFormats()->ContainsFormat(dynamic_cast<const SwFrameFormat&>(rFormat))) + auto pTableFormat = dynamic_cast<const SwTableFormat*>(&rFormat); + if (pTableFormat && pDoc->GetTableFrameFormats()->ContainsFormat(const_cast<SwTableFormat*>(pTableFormat))) { // Table Format: save table position, table formats are volatile! SwTable * pTable = SwIterator<SwTable,SwFormat>( rFormat ).First(); diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index a71a650794a9..627ab4bf870c 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -874,7 +874,7 @@ uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nInputIndex) size_t nIndex = static_cast<size_t>(nInputIndex); size_t nCurrentIndex = 0; - for (SwFrameFormat* const & pFormat : *GetDoc()->GetTableFrameFormats()) + for(SwTableFormat* pFormat: *GetDoc()->GetTableFrameFormats()) { if (!pFormat->GetInfo(aGetHt)) { diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 8a916cf589ef..0f0faa227351 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -4420,7 +4420,7 @@ sal_Bool SAL_CALL SwXTextTableStyle::isInUse() SwAutoFormatGetDocNode aGetHt( &m_pDocShell->GetDoc()->GetNodes() ); - for (SwFrameFormat* const & pFormat : *m_pDocShell->GetDoc()->GetTableFrameFormats()) + for (const SwTableFormat* pFormat : *m_pDocShell->GetDoc()->GetTableFrameFormats()) { if (!pFormat->GetInfo(aGetHt)) { diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index f09f8f22c69a..85c69f7637e7 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2972,10 +2972,10 @@ void SwXTextTable::setName(const OUString& rName) if(pFormat) { const OUString aOldName( pFormat->GetName() ); - const SwFrameFormats* pFrameFormats = pFormat->GetDoc()->GetTableFrameFormats(); + const sw::TableFrameFormats* pFrameFormats = pFormat->GetDoc()->GetTableFrameFormats(); for (size_t i = pFrameFormats->size(); i;) { - const SwFrameFormat* pTmpFormat = (*pFrameFormats)[--i]; + const SwTableFormat* pTmpFormat = (*pFrameFormats)[--i]; if( !pTmpFormat->IsDefault() && pTmpFormat->GetName() == rName && pFormat->GetDoc()->IsUsed( *pTmpFormat )) diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index cbb0cba64edc..86975a413004 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -488,12 +488,11 @@ void SwContentType::FillMemberList(bool* pbContentChanged) case ContentTypeId::TABLE : { const size_t nCount = m_pWrtShell->GetTableFrameFormatCount(true); - const SwFrameFormats* pFrameFormats = m_pWrtShell->GetDoc()->GetTableFrameFormats(); + const sw::TableFrameFormats* pFrameFormats = m_pWrtShell->GetDoc()->GetTableFrameFormats(); SwAutoFormatGetDocNode aGetHt(&m_pWrtShell->GetNodes()); for(size_t n = 0, i = 0; i < nCount + n; ++i) { - const SwTableFormat& rTableFormat = - *static_cast<SwTableFormat*>(pFrameFormats->GetFormat(i)); + const SwTableFormat& rTableFormat = *(*pFrameFormats)[i]; if (rTableFormat.GetInfo(aGetHt)) // skip deleted tables { n++; @@ -5445,10 +5444,8 @@ void SwContentTree::BringEntryToAttention(const weld::TreeIter& rEntry) } else if (nType == ContentTypeId::TABLE) { - if (const SwFrameFormats* pFrameFormats = - m_pActiveShell->GetDoc()->GetTableFrameFormats()) - if (const SwFrameFormat* pFrameFormat = - pFrameFormats->FindFormatByName(pCnt->GetName())) + if (const sw::TableFrameFormats* pFrameFormats = m_pActiveShell->GetDoc()->GetTableFrameFormats()) + if (const SwTableFormat* pFrameFormat = pFrameFormats->FindFrameFormatByName(pCnt->GetName())) { SwTable* pTable = SwTable::FindTable(pFrameFormat); if (pTable) @@ -5545,13 +5542,11 @@ void SwContentTree::BringEntryToAttention(const weld::TreeIter& rEntry) { std::vector<const SwNode*> aNodesArr; const size_t nCount = m_pActiveShell->GetTableFrameFormatCount(false); - const SwFrameFormats* pFrameFormats = - m_pActiveShell->GetDoc()->GetTableFrameFormats(); + const sw::TableFrameFormats& rTableFormats = *m_pActiveShell->GetDoc()->GetTableFrameFormats(); SwAutoFormatGetDocNode aGetHt(&m_pActiveShell->GetNodes()); for(size_t i = 0; i < nCount; ++i) { - if (const SwTableFormat* pTableFormat = - static_cast<SwTableFormat*>(pFrameFormats->GetFormat(i))) + if (const SwTableFormat* pTableFormat = rTableFormats[i]) if (!pTableFormat->GetInfo(aGetHt)) // skip deleted tables { SwTable* pTable = SwTable::FindTable(pTableFormat); |