LibreOffice Module connectivity (master) 1
macaborder.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include "macaborder.hxx"
22#include "MacabHeader.hxx"
23#include "MacabRecord.hxx"
24
25using namespace ::connectivity::macab;
26
27MacabOrder::~MacabOrder()
28{
29}
30
31MacabSimpleOrder::MacabSimpleOrder(MacabHeader const *header, std::u16string_view sColumnName, bool bAscending)
32 : MacabOrder(),
33 m_nFieldNumber(header->getColumnNumber(sColumnName)),
34 m_bAscending(bAscending)
35{
36}
37
38sal_Int32 MacabSimpleOrder::compare(const MacabRecord *record1, const MacabRecord *record2) const
39{
40 sal_Int32 result;
41
43
44 if (!m_bAscending) result = -result;
45
46 return result;
47}
48
50 : MacabOrder(),
51 m_aOrders()
52{
53}
54
56{
57}
58
60{
61 m_aOrders.emplace_back(pOrder);
62}
63
64sal_Int32 MacabComplexOrder::compare(const MacabRecord *record1, const MacabRecord *record2) const
65{
66 for (auto const & p: m_aOrders)
67 {
68 sal_Int32 result = p->compare(record1, record2);
69
70 if (result) return result;
71 }
72 return 0;
73}
74
75/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_Int8 header[]
void addOrder(MacabOrder *pOrder)
Definition: macaborder.cxx:59
virtual sal_Int32 compare(const MacabRecord *record1, const MacabRecord *record2) const override
Definition: macaborder.cxx:64
std::vector< std::unique_ptr< MacabOrder > > m_aOrders
Definition: macaborder.hxx:53
macabfield * get(const sal_Int32 i) const
static sal_Int32 compareFields(const macabfield *_field1, const macabfield *_field2)
virtual sal_Int32 compare(const MacabRecord *record1, const MacabRecord *record2) const override
Definition: macaborder.cxx:38
void * p
Any result