summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2021-10-16 10:16:37 +0200
committerJulien Nabet <serval2412@yahoo.fr>2021-10-16 19:05:05 +0200
commitf6a5efc7cde6e7d723e05b866bc6de1bb56913b0 (patch)
tree7224b816983b0cbbe758dd3b0b466ef6923986b7 /sc/source/ui
parent62078c534f96e859d4e8c0ead6337a876344e4ab (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>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/app/inputhdl.cxx3
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx7
-rw-r--r--sc/source/ui/condformat/condformatmgr.cxx7
-rw-r--r--sc/source/ui/dialogs/searchresults.cxx9
-rw-r--r--sc/source/ui/docshell/docfunc.cxx3
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.cxx9
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.cxx13
-rw-r--r--sc/source/ui/namedlg/namemgrtable.cxx6
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx3
-rw-r--r--sc/source/ui/vba/vbawindow.cxx3
-rw-r--r--sc/source/ui/view/tabvwshf.cxx3
11 files changed, 39 insertions, 27 deletions
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 );
}
}