diff options
Diffstat (limited to 'sw/source/core/doc')
-rw-r--r-- | sw/source/core/doc/DocumentStylePoolManager.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 14 |
4 files changed, 18 insertions, 27 deletions
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 49e399a78a07..858addfb27ec 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -1431,7 +1431,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) SwFormatsBase* pArray[ 2 ]; sal_uInt16 nArrCnt = 1; const char* pRCId = nullptr; - sal_uInt16 const * pWhichRange = nullptr; + WhichRangesContainer const * pWhichRange = nullptr; switch( nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) ) { @@ -1439,7 +1439,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) { pArray[0] = m_rDoc.GetCharFormats(); pDeriveFormat = m_rDoc.GetDfltCharFormat(); - pWhichRange = aCharFormatSetRange; + pWhichRange = &aCharFormatSetRange; if (nId >= RES_POOLCHR_HTML_BEGIN && nId < RES_POOLCHR_HTML_END) pRCId = STR_POOLCHR_HTML_ARY[nId - RES_POOLCHR_HTML_BEGIN]; @@ -1459,7 +1459,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) pArray[1] = m_rDoc.GetSpzFrameFormats(); pDeriveFormat = m_rDoc.GetDfltFrameFormat(); nArrCnt = 2; - pWhichRange = aFrameFormatSetRange; + pWhichRange = &aFrameFormatSetRange; // Fault: unknown Format, but a FrameFormat // -> return the first one @@ -1491,7 +1491,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) } OUString aNm(SwResId(pRCId)); - SwAttrSet aSet( m_rDoc.GetAttrPool(), pWhichRange ); + SwAttrSet aSet( m_rDoc.GetAttrPool(), pWhichRange ? *pWhichRange : WhichRangesContainer() ); { bool bIsModified = m_rDoc.getIDocumentState().IsModified(); diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 9efeb5c1ec75..66ca0bb4c3ed 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -307,19 +307,14 @@ void SaveRedlEndPosForRestore::Restore() } /// Convert list of ranges of whichIds to a corresponding list of whichIds -static std::vector<sal_uInt16> lcl_RangesToVector(const sal_uInt16 * pRanges) +static std::vector<sal_uInt16> lcl_RangesToVector(const WhichRangesContainer& pRanges) { std::vector<sal_uInt16> aResult; - int i = 0; - while (pRanges[i] != 0) + for(const WhichPair& rPair : pRanges) { - OSL_ENSURE(pRanges[i+1] != 0, "malformed ranges"); - - for (sal_uInt16 j = pRanges[i]; j <= pRanges[i+1]; j++) + for (sal_uInt16 j = rPair.first; j <= rPair.second; j++) aResult.push_back(j); - - i += 2; } return aResult; diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index fd6346b33ffc..d3b742ee9f93 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1834,19 +1834,17 @@ void SwDoc::SetFormatItemByAutoFormat( const SwPaM& rPam, const SfxItemSet& rSet } const sal_Int32 nEnd(rPam.End()->nContent.GetIndex()); - std::vector<sal_uInt16> whichIds; + std::vector<WhichPair> whichIds; SfxItemIter iter(rSet); for (SfxPoolItem const* pItem = iter.GetCurItem(); pItem; pItem = iter.NextItem()) { - whichIds.push_back(pItem->Which()); - whichIds.push_back(pItem->Which()); + whichIds.push_back({pItem->Which(), pItem->Which()}); } - whichIds.push_back(0); - SfxItemSet currentSet(GetAttrPool(), whichIds.data()); + SfxItemSet currentSet(GetAttrPool(), WhichRangesContainer(whichIds.data(), whichIds.size())); pTNd->GetParaAttr(currentSet, nEnd, nEnd); - for (size_t i = 0; whichIds[i]; i += 2) + for (const WhichPair& rPair : whichIds) { // yuk - want to explicitly set the pool defaults too :-/ - currentSet.Put(currentSet.Get(whichIds[i])); + currentSet.Put(currentSet.Get(rPair.first)); } getIDocumentContentOperations().InsertItemSet( rPam, rSet, SetAttrMode::DONTEXPAND ); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index b1ed62e0bccc..53ccf3c902c1 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -844,23 +844,21 @@ void SwDoc::InitTOXTypes() void SwDoc::ReplaceDefaults(const SwDoc& rSource) { // copy property defaults - const sal_uInt16 aRangeOfDefaults[] = - { + static const WhichRangesContainer aRangeOfDefaults(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_PARATR_BEGIN, RES_PARATR_END-1, RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, - XATTR_START, XATTR_END-1, - 0 - }; + XATTR_START, XATTR_END-1 + >::value); SfxItemSet aNewDefaults(GetAttrPool(), aRangeOfDefaults); - for (auto nRange = 0; aRangeOfDefaults[nRange] != 0; nRange += 2) + for (const WhichPair& rPair : aRangeOfDefaults) { - for (sal_uInt16 nWhich = aRangeOfDefaults[nRange]; - nWhich <= aRangeOfDefaults[nRange + 1]; ++nWhich) + for (sal_uInt16 nWhich = rPair.first; + nWhich <= rPair.second; ++nWhich) { const SfxPoolItem& rSourceAttr = rSource.mpAttrPool->GetDefaultItem(nWhich); |