summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-06-22 19:39:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-06-22 21:43:09 +0200
commitb2331179fc508fd6bc37355e5c3c5a5ee54557c4 (patch)
tree83f71142c3535cf0054e4237069b819046edb2a8 /sw/source
parentc85d8b23c2339958f59dbc66a9ba4ec114125514 (diff)
Move SwDoc::FindFormatByName to SwFormatsBase
in preparation for adding optimised implementations of it for subclasses Change-Id: I6d8ff54864d2d3c605a1cd0b4da2c6136e2a21cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117672 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/attr/format.cxx19
-rw-r--r--sw/source/core/doc/docfmt.cxx30
-rw-r--r--sw/source/core/docnode/ndtbl.cxx2
-rw-r--r--sw/source/core/undo/unattr.cxx6
4 files changed, 30 insertions, 27 deletions
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 7efb53cd7e45..676adf89fcf7 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -765,4 +765,23 @@ void SwFormat::RemoveAllUnos()
SwPtrMsgPoolItem aMsgHint(RES_REMOVE_UNO_OBJECT, this);
SwClientNotify(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint));
}
+
+SwFormatsBase::~SwFormatsBase()
+{}
+
+SwFormat* SwFormatsBase::FindFormatByName( std::u16string_view rName ) const
+{
+ SwFormat* pFnd = nullptr;
+ for( size_t n = 0; n < GetFormatCount(); ++n )
+ {
+ // Does the Doc already contain the template?
+ if( GetFormat(n)->HasName( rName ) )
+ {
+ pFnd = GetFormat(n);
+ break;
+ }
+ }
+ return pFnd;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index f3c4b71653ac..c45e268c26fc 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -733,7 +733,7 @@ void SwDoc::DelTableFrameFormat( SwTableFormat *pFormat )
SwFrameFormat* SwDoc::FindFrameFormatByName( std::u16string_view rName ) const
{
- return static_cast<SwFrameFormat*>(FindFormatByName( static_cast<SwFormatsBase&>(*mpFrameFormatTable), rName ));
+ return mpFrameFormatTable->FindFormatByName( rName );
}
/// Create the formats
@@ -1231,7 +1231,7 @@ SwTextFormatColl* SwDoc::CopyTextColl( const SwTextFormatColl& rColl )
/// copy the graphic nodes
SwGrfFormatColl* SwDoc::CopyGrfColl( const SwGrfFormatColl& rColl )
{
- SwGrfFormatColl* pNewColl = static_cast<SwGrfFormatColl*>(FindFormatByName( static_cast<SwFormatsBase const &>(*mpGrfFormatCollTable), rColl.GetName() ));
+ SwGrfFormatColl* pNewColl = mpGrfFormatCollTable->FindFormatByName( rColl.GetName() );
if( pNewColl )
return pNewColl;
@@ -1269,7 +1269,7 @@ void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr,
if( pSrc->IsDefault() || pSrc->IsAuto() )
continue;
- if( nullptr == FindFormatByName( rDestArr, pSrc->GetName() ) )
+ if( nullptr == rDestArr.FindFormatByName( pSrc->GetName() ) )
{
if( RES_CONDTXTFMTCOLL == pSrc->Which() )
MakeCondTextFormatColl( pSrc->GetName(), static_cast<SwTextFormatColl*>(&rDfltFormat) );
@@ -1286,7 +1286,7 @@ void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr,
if( pSrc->IsDefault() || pSrc->IsAuto() )
continue;
- pDest = FindFormatByName( rDestArr, pSrc->GetName() );
+ pDest = rDestArr.FindFormatByName( pSrc->GetName() );
pDest->SetAuto(false);
pDest->DelDiffs( *pSrc );
@@ -1320,7 +1320,7 @@ void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr,
pDest->SetPoolHlpFileId( UCHAR_MAX );
if( pSrc->DerivedFrom() )
- pDest->SetDerivedFrom( FindFormatByName( rDestArr,
+ pDest->SetDerivedFrom( rDestArr.FindFormatByName(
pSrc->DerivedFrom()->GetName() ) );
if( RES_TXTFMTCOLL == pSrc->Which() ||
RES_CONDTXTFMTCOLL == pSrc->Which() )
@@ -1328,8 +1328,8 @@ void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr,
SwTextFormatColl* pSrcColl = static_cast<SwTextFormatColl*>(pSrc),
* pDstColl = static_cast<SwTextFormatColl*>(pDest);
if( &pSrcColl->GetNextTextFormatColl() != pSrcColl )
- pDstColl->SetNextTextFormatColl( *static_cast<SwTextFormatColl*>(FindFormatByName(
- rDestArr, pSrcColl->GetNextTextFormatColl().GetName() ) ) );
+ pDstColl->SetNextTextFormatColl(
+ *static_cast<SwTextFormatColl*>(rDestArr.FindFormatByName( pSrcColl->GetNextTextFormatColl().GetName() )) );
if(pSrcColl->IsAssignedToListLevelOfOutlineStyle())
pDstColl->AssignToListLevelOfOutlineStyle(pSrcColl->GetAssignedOutlineStyleLevel());
@@ -1626,22 +1626,6 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles )
getIDocumentState().SetModified();
}
-SwFormat* SwDoc::FindFormatByName( const SwFormatsBase& rFormatArr,
- std::u16string_view rName )
-{
- SwFormat* pFnd = nullptr;
- for( size_t n = 0; n < rFormatArr.GetFormatCount(); ++n )
- {
- // Does the Doc already contain the template?
- if( rFormatArr.GetFormat(n)->HasName( rName ) )
- {
- pFnd = rFormatArr.GetFormat(n);
- break;
- }
- }
- return pFnd;
-}
-
void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus,
SwRootFrame const*const pLayout)
{
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index a17ce9b3e041..654cae173fe4 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3949,7 +3949,7 @@ SwTableFormat* SwDoc::FindTableFormatByName( std::u16string_view rName, bool bAl
{
const SwFormat* pRet = nullptr;
if( bAll )
- pRet = FindFormatByName( *mpTableFrameFormatTable, rName );
+ pRet = mpTableFrameFormatTable->FindFormatByName( rName );
else
{
// Only the ones set in the Doc
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 160a983b1c00..a4c1aaec54d9 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -209,7 +209,7 @@ SwFormat* SwUndoFormatAttr::GetFormat( const SwDoc& rDoc )
return rDoc.FindTextFormatCollByName(m_sFormatName);
case RES_GRFFMTCOLL:
- return SwDoc::FindFormatByName(*rDoc.GetGrfFormatColls(), m_sFormatName);
+ return rDoc.GetGrfFormatColls()->FindFormatByName(m_sFormatName);
case RES_CHRFMT:
return rDoc.FindCharFormatByName(m_sFormatName);
@@ -244,10 +244,10 @@ SwFormat* SwUndoFormatAttr::GetFormat( const SwDoc& rDoc )
case RES_DRAWFRMFMT:
case RES_FLYFRMFMT:
{
- SwFormat * pFormat = SwDoc::FindFormatByName(*rDoc.GetSpzFrameFormats(), m_sFormatName);
+ SwFormat * pFormat = rDoc.GetSpzFrameFormats()->FindFormatByName(m_sFormatName);
if (pFormat)
return pFormat;
- pFormat = SwDoc::FindFormatByName(*rDoc.GetFrameFormats(), m_sFormatName);
+ pFormat = rDoc.GetFrameFormats()->FindFormatByName(m_sFormatName);
if (pFormat)
return pFormat;
}