tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / core / data / columnset.cxx
blob5f91dd8c601a4dca52a74b572179cad6d1f20f80
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <columnset.hxx>
11 #include <algorithm>
13 namespace sc {
15 void ColumnSet::set(SCTAB nTab, SCCOL nCol)
17 TabsType::iterator itTab = maTabs.find(nTab);
18 if (itTab == maTabs.end())
20 std::pair<TabsType::iterator,bool> r =
21 maTabs.emplace(nTab, ColsType());
23 if (!r.second)
24 // insertion failed.
25 return;
27 itTab = r.first;
30 ColsType& rCols = itTab->second;
31 rCols.insert(nCol);
34 void ColumnSet::getColumns(SCTAB nTab, std::vector<SCCOL>& rCols) const
36 std::vector<SCCOL> aCols;
37 TabsType::const_iterator itTab = maTabs.find(nTab);
38 if (itTab == maTabs.end())
40 rCols.swap(aCols); // empty it.
41 return;
44 const ColsType& rTabCols = itTab->second;
45 aCols.assign(rTabCols.begin(), rTabCols.end());
47 // Sort and remove duplicates.
48 std::sort(aCols.begin(), aCols.end());
49 std::vector<SCCOL>::iterator itCol = std::unique(aCols.begin(), aCols.end());
50 aCols.erase(itCol, aCols.end());
52 rCols.swap(aCols);
55 bool ColumnSet::hasTab(SCTAB nTab) const
57 return maTabs.find(nTab) != maTabs.end();
60 bool ColumnSet::empty() const
62 return maTabs.empty();
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */