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"
14 void ColumnSet::set(SCTAB nTab
, SCCOL nCol
)
16 TabsType::iterator itTab
= maTabs
.find(nTab
);
17 if (itTab
== maTabs
.end())
19 std::pair
<TabsType::iterator
,bool> r
=
20 maTabs
.insert(TabsType::value_type(nTab
, ColsType()));
29 ColsType
& rCols
= itTab
->second
;
33 bool ColumnSet::has(SCTAB nTab
, SCCOL nCol
) const
35 TabsType::const_iterator itTab
= maTabs
.find(nTab
);
36 if (itTab
== maTabs
.end())
39 const ColsType
& rCols
= itTab
->second
;
40 return rCols
.count(nCol
) > 0;
43 void ColumnSet::getColumns(SCTAB nTab
, std::vector
<SCCOL
>& rCols
) const
45 std::vector
<SCCOL
> aCols
;
46 TabsType::const_iterator itTab
= maTabs
.find(nTab
);
47 if (itTab
== maTabs
.end())
49 rCols
.swap(aCols
); // empty it.
53 const ColsType
& rTabCols
= itTab
->second
;
54 aCols
.assign(rTabCols
.begin(), rTabCols
.end());
56 // Sort and remove duplicates.
57 std::sort(aCols
.begin(), aCols
.end());
58 std::vector
<SCCOL
>::iterator itCol
= std::unique(aCols
.begin(), aCols
.end());
59 aCols
.erase(itCol
, aCols
.end());
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */