build fix
[LibreOffice.git] / connectivity / source / drivers / kab / korder.cxx
blob6ff1f0c8915a2322a266242b6a939c57aedbc1a5
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "korder.hxx"
22 #include "kfields.hxx"
24 using namespace ::connectivity::kab;
26 KabOrder::~KabOrder()
30 KabSimpleOrder::KabSimpleOrder(OUString &sColumnName, bool bAscending)
31 : KabOrder(),
32 m_nFieldNumber(findKabField(sColumnName)),
33 m_bAscending(bAscending)
37 sal_Int32 KabSimpleOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const
39 sal_Int32 result;
41 result = QString::compare(
42 valueOfKabField(aAddressee1, m_nFieldNumber),
43 valueOfKabField(aAddressee2, m_nFieldNumber));
44 // Timestamps should be compared differently than with their string value
46 if (!m_bAscending) result = -result;
48 return result;
51 KabComplexOrder::KabComplexOrder()
52 : KabOrder(),
53 m_aOrders()
57 KabComplexOrder::~KabComplexOrder()
59 for (auto p: m_aOrders)
60 delete p;
63 void KabComplexOrder::addOrder(KabOrder *pOrder)
65 m_aOrders.push_back(pOrder);
68 sal_Int32 KabComplexOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const
70 for (auto p: m_aOrders)
72 sal_Int32 result = p->compare(aAddressee1, aAddressee2);
74 if (result) return result;
76 return 0;
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */