1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <columnset.hxx>
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());
30 ColsType
& rCols
= itTab
->second
;
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.
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());
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: */