diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-10-16 10:16:37 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-10-16 19:05:05 +0200 |
commit | f6a5efc7cde6e7d723e05b866bc6de1bb56913b0 (patch) | |
tree | 7224b816983b0cbbe758dd3b0b466ef6923986b7 | |
parent | 62078c534f96e859d4e8c0ead6337a876344e4ab (diff) |
Simplify vector initialization in sc
Change-Id: If5b7632cfbc81f89d68ce8fbce1fac265e8354fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123692
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r-- | sc/qa/unit/pivottable_filters_test.cxx | 7 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sharedformula.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/dpfilteredcache.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 18 | ||||
-rw-r--r-- | sc/source/core/tool/interpr8.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/xlroot.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatmgr.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/dialogs/searchresults.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/conflictsdlg.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/sharedocdlg.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/namedlg/namemgrtable.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/vba/excelvbahelper.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/vba/vbawindow.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 3 |
19 files changed, 59 insertions, 59 deletions
diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx index cfca0c29cadf..8ad8fbffee81 100644 --- a/sc/qa/unit/pivottable_filters_test.cxx +++ b/sc/qa/unit/pivottable_filters_test.cxx @@ -432,11 +432,8 @@ void ScPivotTableFiltersTest::testPivotTableSharedCacheGroupODS() } std::sort(aGrpValues.begin(), aGrpValues.end()); - std::vector<sal_Int32> aChecks; - aChecks.push_back(ScDPItemData::DateFirst); - aChecks.push_back(2012); - aChecks.push_back(2013); - aChecks.push_back(ScDPItemData::DateLast); + std::vector<sal_Int32> aChecks{ ScDPItemData::DateFirst, 2012, 2013, + ScDPItemData::DateLast }; CPPUNIT_ASSERT_MESSAGE("Unexpected group values for the year group.", bool(aGrpValues == aChecks)); } diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 1f7bc50ed2f5..3e96ed80ce57 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1550,10 +1550,7 @@ void TestSharedFormula::testSharedFormulaMoveBlock() clearFormulaCellChangedFlag(*m_pDoc, aFormulaRange); // Make sure these formula cells in B1:B3 have correct positions even after the move. - std::vector<SCROW> aRows; - aRows.push_back(0); - aRows.push_back(1); - aRows.push_back(2); + std::vector<SCROW> aRows { 0, 1, 2 }; bool bRes = checkFormulaPositions(*m_pDoc, 0, 1, aRows.data(), aRows.size()); CPPUNIT_ASSERT(bRes); @@ -1928,8 +1925,7 @@ void TestSharedFormula::testSharedFormulaUnshareAreaListeners() // Set formula cell vector. { ScFormulaCell* pCell = new ScFormulaCell( *m_pDoc, aPos, "=B4"); - std::vector<ScFormulaCell*> aCells; - aCells.push_back(pCell); + std::vector<ScFormulaCell*> aCells { pCell }; m_pDoc->SetFormulaCells( aPos, aCells); } break; diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index f7f7d2a294da..b4491b869966 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -435,8 +435,7 @@ void ScColumn::ConvertFormulaToValue( if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2) return; - std::vector<SCROW> aBounds; - aBounds.push_back(nRow1); + std::vector<SCROW> aBounds { nRow1 }; if (nRow2 < GetDoc().MaxRow()-1) aBounds.push_back(nRow2+1); @@ -496,8 +495,7 @@ void ScColumn::SwapNonEmpty( sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt ) { const ScRange& rRange = rValues.getRange(); - std::vector<SCROW> aBounds; - aBounds.push_back(rRange.aStart.Row()); + std::vector<SCROW> aBounds { rRange.aStart.Row() }; if (rRange.aEnd.Row() < GetDoc().MaxRow()-1) aBounds.push_back(rRange.aEnd.Row()+1); diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx index 16e11c183b83..19b1782076c2 100644 --- a/sc/source/core/data/dpfilteredcache.cxx +++ b/sc/source/core/data/dpfilteredcache.cxx @@ -41,9 +41,7 @@ bool ScDPFilteredCache::SingleFilter::match(const ScDPItemData& rCellData) const std::vector<ScDPItemData> ScDPFilteredCache::SingleFilter::getMatchValues() const { - std::vector<ScDPItemData> aValues; - aValues.push_back(maItem); - return aValues; + return { maItem }; } ScDPFilteredCache::GroupFilter::GroupFilter() diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 740e5fe02157..7e9d569f5668 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3063,8 +3063,7 @@ ScFormulaCell::HasRefListExpressibleAsOneReference(ScRange& rRange) const { // Collect all consecutive references, starting by the one // already found - std::vector<formula::FormulaToken*> aReferences; - aReferences.push_back(pFirstReference); + std::vector<formula::FormulaToken*> aReferences { pFirstReference }; FormulaToken* pToken(aIter.NextRPN()); FormulaToken* pFunction(nullptr); while (pToken) diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 8e576edb6da1..2c2166a47faf 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1138,10 +1138,11 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol // Split formula groups at the sort range boundaries (if applicable). if (!bOnlyDataAreaExtras) { - std::vector<SCROW> aRowBounds; - aRowBounds.reserve(2); - aRowBounds.push_back(nRow1); - aRowBounds.push_back(nRow2+1); + std::vector<SCROW> aRowBounds + { + nRow1, + nRow2+1 + }; for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) SplitFormulaGroups(nCol, aRowBounds); } @@ -1331,10 +1332,11 @@ void ScTable::SortReorderByRowRefUpdate( } // Split formula groups at the sort range boundaries (if applicable). - std::vector<SCROW> aRowBounds; - aRowBounds.reserve(2); - aRowBounds.push_back(nRow1); - aRowBounds.push_back(nRow2+1); + std::vector<SCROW> aRowBounds + { + nRow1, + nRow2+1 + }; for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) SplitFormulaGroups(nCol, aRowBounds); diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx index 690660acce5f..b11ccec62428 100644 --- a/sc/source/core/tool/interpr8.cxx +++ b/sc/source/core/tool/interpr8.cxx @@ -275,8 +275,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co case 5 : // MEDIAN { - std::vector< double > aTmp; - aTmp.push_back( maRange[ i - 1 ].Y ); + std::vector< double > aTmp { maRange[ i - 1 ].Y }; while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X ) { aTmp.push_back( maRange[ i ].Y ); diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx index bc0f52ca9f10..bac3ca1b3f59 100644 --- a/sc/source/filter/excel/xlroot.cxx +++ b/sc/source/filter/excel/xlroot.cxx @@ -248,8 +248,7 @@ sal_Int32 XclRoot::GetHmmFromPixelY( double fPixelY ) const uno::Sequence< beans::NamedValue > XclRoot::RequestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier ) const { - ::std::vector< OUString > aDefaultPasswords; - aDefaultPasswords.push_back( XclRootData::gaDefPassword ); + ::std::vector< OUString > aDefaultPasswords { XclRootData::gaDefPassword }; return ScfApiHelper::QueryEncryptionDataForMedium( mrData.mrMedium, rVerifier, &aDefaultPasswords ); } diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 9779b6e9692a..9c553cec8614 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1316,8 +1316,7 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult ) if ( p == maFormulaChar.end() ) return false; // last character is not part of any function name, quit - ::std::vector<sal_Unicode> aTemp; - aTemp.push_back( c ); + ::std::vector<sal_Unicode> aTemp { c }; for(sal_Int32 i = nPos - 1; i >= 0; --i) { c = aStart[ i ]; diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 7556ac5e4737..e96f06c4d63d 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -18,6 +18,7 @@ */ #include <checklistmenu.hxx> +#include <o3tl/safeint.hxx> #include <globstr.hrc> #include <scresid.hxx> @@ -150,8 +151,10 @@ void ScCheckListMenuControl::addSeparator() IMPL_LINK(ScCheckListMenuControl, TreeSizeAllocHdl, const Size&, rSize, void) { assert(mbCanHaveSubMenu); - std::vector<int> aWidths; - aWidths.push_back(rSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6); + std::vector<int> aWidths + { + o3tl::narrowing<int>(rSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6) + }; mxMenu->set_column_fixed_widths(aWidths); } diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index 03530ccc42fb..06954a7f65d1 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -12,6 +12,7 @@ #include <condformatdlg.hxx> #include <document.hxx> #include <conditio.hxx> +#include <o3tl/safeint.hxx> ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView, ScDocument& rDoc, ScConditionalFormatList* pFormatList) @@ -76,8 +77,10 @@ ScConditionalFormat* ScCondFormatManagerWindow::GetSelection() void ScCondFormatManagerWindow::setColSizes() { - std::vector<int> aWidths; - aWidths.push_back(mrTreeView.get_size_request().Width() / 2); + std::vector<int> aWidths + { + o3tl::narrowing<int>(mrTreeView.get_size_request().Width() / 2) + }; mrTreeView.set_column_fixed_widths(aWidths); } diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx index db9dae68bfc8..ab0e5790705b 100644 --- a/sc/source/ui/dialogs/searchresults.cxx +++ b/sc/source/ui/dialogs/searchresults.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <o3tl/safeint.hxx> #include <searchresults.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> @@ -33,9 +34,11 @@ SearchResultsDlg::SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParen { mxList->set_size_request(mxList->get_approximate_digit_width() * 50, mxList->get_height_rows(15)); mxShowDialog->connect_toggled(LINK(this, SearchResultsDlg, OnShowToggled)); - std::vector<int> aWidths; - aWidths.push_back(mxList->get_approximate_digit_width() * 10); - aWidths.push_back(mxList->get_approximate_digit_width() * 10); + std::vector<int> aWidths + { + o3tl::narrowing<int>(mxList->get_approximate_digit_width() * 10), + o3tl::narrowing<int>(mxList->get_approximate_digit_width() * 10) + }; mxList->set_column_fixed_widths(aWidths); mxList->connect_changed(LINK(this, SearchResultsDlg, ListSelectHdl)); mxList->connect_column_clicked(LINK(this, SearchResultsDlg, HeaderBarClick)); diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index c75dd7e9fb37..123a4c211338 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -3445,8 +3445,7 @@ void ScDocFunc::SetTableVisible( SCTAB nTab, bool bVisible, bool bApi ) rDoc.SetVisible( nTab, bVisible ); if (bUndo) { - std::vector<SCTAB> undoTabs; - undoTabs.push_back(nTab); + std::vector<SCTAB> undoTabs { nTab }; rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( &rDocShell, std::move(undoTabs), bVisible ) ); } diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx index 876febabfa76..d3a79455698a 100644 --- a/sc/source/ui/miscdlgs/conflictsdlg.cxx +++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx @@ -21,6 +21,7 @@ #include <osl/diagnose.h> #include <conflictsdlg.hxx> +#include <o3tl/safeint.hxx> #include <strings.hrc> #include <scresid.hxx> #include <viewdata.hxx> @@ -355,9 +356,11 @@ ScConflictsDlg::ScConflictsDlg(weld::Window* pParent, ScViewData* pViewData, ScD weld::TreeView& rTreeView = m_xLbConflicts->GetWidget(); auto nDigitWidth = rTreeView.get_approximate_digit_width(); - std::vector<int> aWidths; - aWidths.push_back(nDigitWidth * 60); - aWidths.push_back(nDigitWidth * 20); + std::vector<int> aWidths + { + o3tl::narrowing<int>(nDigitWidth * 60), + o3tl::narrowing<int>(nDigitWidth * 20) + }; rTreeView.set_column_fixed_widths(aWidths); rTreeView.set_selection_mode(SelectionMode::Multiple); diff --git a/sc/source/ui/miscdlgs/sharedocdlg.cxx b/sc/source/ui/miscdlgs/sharedocdlg.cxx index 9910db9e47e5..ec019fb70655 100644 --- a/sc/source/ui/miscdlgs/sharedocdlg.cxx +++ b/sc/source/ui/miscdlgs/sharedocdlg.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <o3tl/safeint.hxx> #include <osl/security.hxx> #include <osl/diagnose.h> #include <sfx2/dialoghelper.hxx> @@ -39,9 +40,11 @@ using namespace ::com::sun::star; IMPL_LINK(ScShareDocumentDlg, SizeAllocated, const Size&, rSize, void) { OUString sWidestAccessString = getWidestTime(ScGlobal::getLocaleData()); - std::vector<int> aWidths; const int nAccessWidth = m_xLbUsers->get_pixel_size(sWidestAccessString).Width() * 2; - aWidths.push_back(rSize.Width() - nAccessWidth); + std::vector<int> aWidths + { + o3tl::narrowing<int>(rSize.Width() - nAccessWidth) + }; m_xLbUsers->set_column_fixed_widths(aWidths); } @@ -62,8 +65,10 @@ ScShareDocumentDlg::ScShareDocumentDlg(weld::Window* pParent, const ScViewData* mpDocShell = ( pViewData ? pViewData->GetDocShell() : nullptr ); OSL_ENSURE( mpDocShell, "ScShareDocumentDlg CTOR: mpDocShell is null!" ); - std::vector<int> aWidths; - aWidths.push_back(m_xLbUsers->get_approximate_digit_width() * 25); + std::vector<int> aWidths + { + o3tl::narrowing<int>(m_xLbUsers->get_approximate_digit_width() * 25) + }; m_xLbUsers->set_column_fixed_widths(aWidths); m_xLbUsers->set_size_request(-1, m_xLbUsers->get_height_rows(9)); diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx index 0309931b7cf3..a48352a26083 100644 --- a/sc/source/ui/namedlg/namemgrtable.cxx +++ b/sc/source/ui/namedlg/namemgrtable.cxx @@ -11,6 +11,7 @@ #include <memory> #include <global.hxx> #include <globstr.hrc> +#include <o3tl/safeint.hxx> #include <scresid.hxx> #include <globalnames.hxx> #include <namemgrtable.hxx> @@ -63,9 +64,8 @@ ScRangeManagerTable::ScRangeManagerTable( , mbNeedUpdate(true) { auto nColWidth = m_xTreeView->get_size_request().Width() / 7; - std::vector<int> aWidths; - aWidths.push_back(nColWidth * 2); - aWidths.push_back(nColWidth * 3); + std::vector<int> aWidths{ o3tl::narrowing<int>(nColWidth * 2), + o3tl::narrowing<int>(nColWidth * 3) }; m_xTreeView->set_column_fixed_widths(aWidths); Init(); diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 0453f6b4bb44..d337a0f6836e 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -347,8 +347,7 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& rDoc.SetCodeName( sCodeName ); } - std::vector< OUString > sDocModuleNames; - sDocModuleNames.push_back( sCodeName ); + std::vector< OUString > sDocModuleNames { sCodeName }; for ( SCTAB index = 0; index < rDoc.GetTableCount(); index++) { diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index f43775f1fc88..4bb77c5d8971 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -727,8 +727,7 @@ void SAL_CALL ScVbaWindow::setZoom(const uno::Any& _zoom) SCTAB nTab = 0; if ( !ScVbaWorksheets::nameExists (xSpreadDoc, xActiveSheet->getName(), nTab) ) throw uno::RuntimeException(); - std::vector< SCTAB > vTabs; - vTabs.push_back( nTab ); + std::vector< SCTAB > vTabs { nTab }; excel::implSetZoom( m_xModel, nZoom, vTabs ); } diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 41f53159b174..ba800ef75234 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -96,8 +96,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) } else // fade in { - std::vector<OUString> rNames; - rNames.push_back(aName); + std::vector<OUString> rNames { aName }; ShowTable( rNames ); } } |