From 8ec8bbcd4b1af73527859255d84af9f5990426bb Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sat, 16 Oct 2021 14:18:43 +0200 Subject: Simplify vector initialization in sw Change-Id: Ibded138d113e56b78b12c96c7ecd8258564627ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123701 Tested-by: Jenkins Reviewed-by: Julien Nabet --- sw/source/core/docnode/node.cxx | 8 ++----- sw/source/core/table/swtable.cxx | 3 +-- sw/source/core/txtnode/ndtxt.cxx | 4 +--- sw/source/filter/ww8/docxexport.cxx | 7 ++---- sw/source/filter/ww8/rtfattributeoutput.cxx | 18 +++++++-------- sw/source/filter/ww8/rtfexport.cxx | 15 +++++-------- sw/source/filter/ww8/ww8par2.cxx | 34 ++++++++++++++--------------- sw/source/ui/chrdlg/swuiccoll.cxx | 7 ++++-- sw/source/ui/dbui/addresslistdialog.cxx | 7 ++++-- sw/source/ui/dbui/mmoutputtypepage.cxx | 8 ++++--- sw/source/ui/dbui/selectdbtabledialog.cxx | 4 ++-- sw/source/ui/index/cnttab.cxx | 9 ++++---- sw/source/ui/misc/bookmark.cxx | 7 +----- sw/source/ui/misc/glosbib.cxx | 4 +--- sw/source/uibase/uiview/pview.cxx | 16 +++++++++----- sw/source/uibase/uiview/view2.cxx | 8 ++++--- 16 files changed, 76 insertions(+), 83 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 7c0403239130..e2598a1a53bd 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1668,9 +1668,7 @@ bool SwContentNode::ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 ) sal_uInt16 nDel = 0; if ( !nWhich2 || nWhich2 < nWhich1 ) { - std::vector aClearWhichIds; - aClearWhichIds.push_back( nWhich1 ); - nDel = ClearItemsFromAttrSet( aClearWhichIds ); + nDel = ClearItemsFromAttrSet( { nWhich1 } ); } else nDel = AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, nWhich1, nWhich2, nullptr, nullptr ); @@ -1736,9 +1734,7 @@ sal_uInt16 SwContentNode::ResetAllAttr() // If Modify is locked, do not send out any Modifys if( IsModifyLocked() ) { - std::vector aClearWhichIds; - aClearWhichIds.push_back(0); - sal_uInt16 nDel = ClearItemsFromAttrSet( aClearWhichIds ); + sal_uInt16 nDel = ClearItemsFromAttrSet( { 0 } ); if( !GetpSwAttrSet()->Count() ) // Empty? Delete mpAttrSet.reset(); return nDel; diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index ff85241e1cdf..c3b508493667 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1045,9 +1045,8 @@ static void lcl_CalcNewWidths( std::vector &rSpanPos, ChangeList& rC return; } std::vector aNewSpanPos; - ChangeList aNewChanges; ChangeList::iterator pCurr = rChanges.begin(); - aNewChanges.push_back( *pCurr ); // Nullposition + ChangeList aNewChanges { *pCurr }; // Nullposition std::vector::iterator pSpan = rSpanPos.begin(); sal_uInt16 nCurr = 0; SwTwips nOrgSum = 0; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 6ca45bf97a7d..8179e4139f46 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2972,9 +2972,7 @@ SwTextNode* SwTextNode::MakeNewTextNode( const SwNodeIndex& rPos, bool bNext, // #i75353# if ( bClearHardSetNumRuleWhenFormatCollChanges ) { - std::vector aClearWhichIds; - aClearWhichIds.push_back( RES_PARATR_NUMRULE ); - if ( ClearItemsFromAttrSet( aClearWhichIds ) != 0 ) + if ( ClearItemsFromAttrSet( { RES_PARATR_NUMRULE } ) != 0 ) { InvalidateInSwCache(RES_ATTRSET_CHG); } diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index b610adf30f7d..b90fc8c74a02 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -177,11 +177,8 @@ void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos void DocxExport::AppendBookmark( const OUString& rName ) { - std::vector< OUString > aStarts; - std::vector< OUString > aEnds; - - aStarts.push_back( rName ); - aEnds.push_back( rName ); + std::vector< OUString > aStarts { rName }; + std::vector< OUString > aEnds { rName }; m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds ); } diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index b821d632d18a..55926c576d62 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -4242,16 +4242,14 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat m_rExport.SetRTFFlySyntax(false); m_rExport.m_pParentFrame = nullptr; m_pFlyFrameSize = nullptr; - - std::vector> aFlyProperties; - aFlyProperties.push_back(std::make_pair( - "shapeType", OString::number(ESCHER_ShpInst_PictureFrame))); - aFlyProperties.push_back(std::make_pair( - "wzDescription", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjDescription(), - m_rExport.GetCurrentEncoding()))); - aFlyProperties.push_back(std::make_pair( - "wzName", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjTitle(), - m_rExport.GetCurrentEncoding()))); + std::vector> aFlyProperties{ + { "shapeType", OString::number(ESCHER_ShpInst_PictureFrame) }, + + { "wzDescription", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjDescription(), + m_rExport.GetCurrentEncoding()) }, + { "wzName", msfilter::rtfutil::OutString(pFlyFrameFormat->GetObjTitle(), + m_rExport.GetCurrentEncoding()) } + }; // If we have a wrap polygon, then handle that here. if (pFlyFrameFormat->GetSurround().IsContour()) diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 299b7d105754..9396f2422db4 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -144,11 +144,8 @@ void RtfExport::AppendBookmarks(const SwTextNode& rNode, sal_Int32 nCurrentPos, void RtfExport::AppendBookmark(const OUString& rName) { - std::vector aStarts; - std::vector aEnds; - - aStarts.push_back(rName); - aEnds.push_back(rName); + std::vector aStarts{ rName }; + std::vector aEnds{ rName }; m_pAttrOutput->WriteBookmarks_Impl(aStarts, aEnds); } @@ -429,10 +426,10 @@ void RtfExport::WriteMainText() Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHP); Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPINST); - std::vector> aProperties; - aProperties.push_back(std::make_pair("shapeType", "1")); - aProperties.push_back(std::make_pair( - "fillColor", OString::number(wwUtility::RGBToBGR(oBrush->GetColor())))); + std::vector> aProperties{ + { "shapeType", "1" }, + { "fillColor", OString::number(wwUtility::RGBToBGR(oBrush->GetColor())) } + }; for (const std::pair& rPair : aProperties) { Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{"); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 6f7198009f51..6df597fe7cac 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -4067,29 +4067,29 @@ void WW8RStyle::ScanStyles() // investigate style dependencies std::vector ChpxToSprms(const Word2CHPX &rChpx) { - std::vector aRet; - - aRet.push_back(60); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fBold) ); - - aRet.push_back(61); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fItalic) ); + std::vector aRet + { + 60, + static_cast< sal_uInt8 >(128 + rChpx.fBold), - aRet.push_back(62); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fStrike) ); + 61, + static_cast< sal_uInt8 >(128 + rChpx.fItalic), - aRet.push_back(63); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fOutline) ); + 62, + static_cast< sal_uInt8 >(128 + rChpx.fStrike), - aRet.push_back(65); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fSmallCaps) ); + 63, + static_cast< sal_uInt8 >(128 + rChpx.fOutline), - aRet.push_back(66); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fCaps) ); + 65, + static_cast< sal_uInt8 >(128 + rChpx.fSmallCaps), - aRet.push_back(67); - aRet.push_back( static_cast< sal_uInt8 >(128 + rChpx.fVanish) ); + 66, + static_cast< sal_uInt8 >(128 + rChpx.fCaps), + 67, + static_cast< sal_uInt8 >(128 + rChpx.fVanish) + }; if (rChpx.fsFtc) { aRet.push_back(68); diff --git a/sw/source/ui/chrdlg/swuiccoll.cxx b/sw/source/ui/chrdlg/swuiccoll.cxx index f94db2ebaee0..c0953f830ff5 100644 --- a/sw/source/ui/chrdlg/swuiccoll.cxx +++ b/sw/source/ui/chrdlg/swuiccoll.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -49,8 +50,10 @@ SwCondCollPage::SwCondCollPage(weld::Container* pPage, weld::DialogController* p const auto nHeightRequest = m_xStyleLB->get_height_rows(12); m_xStyleLB->set_size_request(-1, nHeightRequest); m_xTbLinks->set_size_request(-1, nHeightRequest); - std::vector aWidths; - aWidths.push_back(m_xTbLinks->get_approximate_digit_width() * 40); + std::vector aWidths + { + o3tl::narrowing(m_xTbLinks->get_approximate_digit_width() * 40) + }; m_xTbLinks->set_column_fixed_widths(aWidths); const sal_Int32 nStrCount = m_xFilterLB->get_count(); diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx index aac1602f3968..2b5933096ac8 100644 --- a/sw/source/ui/dbui/addresslistdialog.cxx +++ b/sw/source/ui/dbui/addresslistdialog.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -147,8 +148,10 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent) m_xListLB->set_size_request(m_xListLB->get_approximate_digit_width() * 52, m_xListLB->get_height_rows(9)); - std::vector aWidths; - aWidths.push_back(m_xListLB->get_approximate_digit_width() * 26); + std::vector aWidths + { + o3tl::narrowing(m_xListLB->get_approximate_digit_width() * 26) + }; m_xListLB->set_column_fixed_widths(aWidths); m_xListLB->make_sorted(); diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx index 27026e86830f..e8c8e35bc3dc 100644 --- a/sw/source/ui/dbui/mmoutputtypepage.cxx +++ b/sw/source/ui/dbui/mmoutputtypepage.cxx @@ -232,9 +232,11 @@ SwSendMailDialog::SwSendMailDialog(weld::Window *pParent, SwMailMergeConfigItem& m_xStop->connect_clicked(LINK( this, SwSendMailDialog, StopHdl_Impl)); m_xCancel->connect_clicked(LINK( this, SwSendMailDialog, CancelHdl_Impl)); - std::vector aWidths; - aWidths.push_back(m_xStatus->get_checkbox_column_width()); - aWidths.push_back(aSize.Width()/3 * 2); + std::vector aWidths + { + o3tl::narrowing(m_xStatus->get_checkbox_column_width()), + o3tl::narrowing(aSize.Width()/3 * 2) + }; m_xStatus->set_column_fixed_widths(aWidths); m_xPaused->set_visible(false); diff --git a/sw/source/ui/dbui/selectdbtabledialog.cxx b/sw/source/ui/dbui/selectdbtabledialog.cxx index e49624e48273..3622a074193e 100644 --- a/sw/source/ui/dbui/selectdbtabledialog.cxx +++ b/sw/source/ui/dbui/selectdbtabledialog.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include "selectdbtabledialog.hxx" #include "dbtablepreviewdialog.hxx" @@ -48,8 +49,7 @@ SwSelectDBTableDialog::SwSelectDBTableDialog(weld::Window* pParent, m_xTable->set_size_request(m_xTable->get_approximate_digit_width() * 60, m_xTable->get_height_rows(6)); - std::vector aWidths; - aWidths.push_back(m_xTable->get_approximate_digit_width() * 30); + std::vector aWidths{ o3tl::narrowing(m_xTable->get_approximate_digit_width() * 30) }; m_xTable->set_column_fixed_widths(aWidths); m_xPreviewPB->connect_clicked(LINK(this, SwSelectDBTableDialog, PreviewHdl)); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index e58de4007613..dad3312e3d5a 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -502,8 +502,10 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent, m_xHeaderTree->enable_toggle_buttons(weld::ColumnToggleType::Radio); m_xHeaderTree->connect_toggled(LINK(this, SwAddStylesDlg_Impl, RadioToggleOnHdl)); - std::vector aWidths; - aWidths.push_back(m_xHeaderTree->get_approximate_digit_width() * 30); + std::vector aWidths + { + o3tl::narrowing(m_xHeaderTree->get_approximate_digit_width() * 30) + }; int nPadding = m_xHeaderTree->get_approximate_digit_width() * 2; OUString sTitle(m_xHeaderTree->get_column_title(1)); for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i) @@ -579,8 +581,7 @@ IMPL_LINK(SwAddStylesDlg_Impl, TreeSizeAllocHdl, const Size&, rSize, void) { auto nWidth = rSize.Width() - Application::GetSettings().GetStyleSettings().GetScrollBarSize(); - std::vector aWidths; - aWidths.push_back(0); + std::vector aWidths { 0 }; int nPadding = m_xHeaderTree->get_approximate_digit_width() * 2; for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i) { diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 54538bd502ff..77ff0b3bbd49 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -388,12 +388,7 @@ BookmarkTable::BookmarkTable(std::unique_ptr xControl) : m_xControl(std::move(xControl)) { m_xControl->set_size_request(450, 250); - std::vector aWidths; - aWidths.push_back(40); - aWidths.push_back(110); - aWidths.push_back(150); - aWidths.push_back(60); - m_xControl->set_column_fixed_widths(aWidths); + m_xControl->set_column_fixed_widths({ 40, 110, 150, 160 }); m_xControl->set_selection_mode(SelectionMode::Multiple); } diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx index c32605370b06..036ca954e680 100644 --- a/sw/source/ui/misc/glosbib.cxx +++ b/sw/source/ui/misc/glosbib.cxx @@ -57,9 +57,7 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(weld::Window * pParent, //just has to be something small, real size will be available space m_xGroupTLB->set_size_request(nWidth, m_xGroupTLB->get_height_rows(10)); - std::vector aWidths; - aWidths.push_back(nWidth); - m_xGroupTLB->set_column_fixed_widths(aWidths); + m_xGroupTLB->set_column_fixed_widths( { nWidth } ); m_xGroupTLB->connect_changed(LINK(this, SwGlossaryGroupDlg, SelectHdl)); m_xNewPB->connect_clicked(LINK(this, SwGlossaryGroupDlg, NewHdl)); diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index dd88a912b10e..165c119e08bc 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -966,9 +966,11 @@ void SwPagePreview::GetState( SfxItemSet& rSet ) case FN_STAT_PAGE: { - std::vector aStringList; - aStringList.push_back(m_sPageStr + m_pViewWin->GetStatusStr(mnPageCount)); - aStringList.push_back(OUString()); + std::vector aStringList + { + m_sPageStr + m_pViewWin->GetStatusStr(mnPageCount), + OUString() + }; rSet.Put(SfxStringListItem(FN_STAT_PAGE, &aStringList)); } break; @@ -1278,9 +1280,11 @@ bool SwPagePreview::ChgPage( int eMvMode, bool bUpdateScrollbar ) }; rBindings.Invalidate( aInval ); } - std::vector aStringList; - aStringList.push_back(m_sPageStr + m_pViewWin->GetStatusStr(mnPageCount)); - aStringList.push_back(OUString()); + std::vector aStringList + { + m_sPageStr + m_pViewWin->GetStatusStr(mnPageCount), + OUString() + }; rBindings.SetState(SfxStringListItem(FN_STAT_PAGE, &aStringList)); } return bChg; diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 61a292279b58..6cb9340b758c 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -1494,14 +1494,16 @@ void SwView::StateStatusLine(SfxItemSet &rSet) sal_uInt16 nPage, nLogPage; OUString sDisplay; rShell.GetPageNumber( -1, rShell.IsCursorVisible(), nPage, nLogPage, sDisplay ); - std::vector aStringList; - aStringList.push_back(GetPageStr(nPage, nLogPage, sDisplay)); bool bExtendedTooltip(!sDisplay.isEmpty() && std::u16string_view(OUString::number(nPage)) != sDisplay && nPage != nLogPage); OUString aTooltip = bExtendedTooltip ? SwResId(STR_BOOKCTRL_HINT_EXTENDED) : SwResId(STR_BOOKCTRL_HINT); - aStringList.push_back(aTooltip); + std::vector aStringList + { + GetPageStr(nPage, nLogPage, sDisplay), + aTooltip + }; rSet.Put(SfxStringListItem(FN_STAT_PAGE, &aStringList)); //if existing page number is not equal to old page number, send out this event. if (m_nOldPageNum != nLogPage ) -- cgit