merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / macab / macaborder.cxx
blob7cce344c95256f2fc702454d807dd0935d550025
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: macaborder.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #include "macaborder.hxx"
35 #include "MacabHeader.hxx"
36 #include "MacabRecord.hxx"
38 using namespace ::connectivity::macab;
40 MacabOrder::~MacabOrder()
43 // -----------------------------------------------------------------------------
44 MacabSimpleOrder::MacabSimpleOrder(MacabHeader *header, ::rtl::OUString &sColumnName, sal_Bool bAscending)
45 : MacabOrder(),
46 m_nFieldNumber(header->getColumnNumber(sColumnName)),
47 m_bAscending(bAscending)
50 // -----------------------------------------------------------------------------
51 sal_Int32 MacabSimpleOrder::compare(const MacabRecord *record1, const MacabRecord *record2) const
53 sal_Int32 result;
55 result = MacabRecord::compareFields(record1->get(m_nFieldNumber), record2->get(m_nFieldNumber));
57 if (!m_bAscending) result = -result;
59 return result;
61 // -----------------------------------------------------------------------------
62 MacabComplexOrder::MacabComplexOrder()
63 : MacabOrder(),
64 m_aOrders()
67 // -----------------------------------------------------------------------------
68 MacabComplexOrder::~MacabComplexOrder()
70 for (sal_uInt32 i = 0; i < m_aOrders.size(); i++)
71 delete m_aOrders[i];
73 // -----------------------------------------------------------------------------
74 void MacabComplexOrder::addOrder(MacabOrder *pOrder)
76 m_aOrders.push_back(pOrder);
78 // -----------------------------------------------------------------------------
79 sal_Int32 MacabComplexOrder::compare(const MacabRecord *record1, const MacabRecord *record2) const
81 for (sal_uInt32 i = 0; i < m_aOrders.size(); i++)
83 const MacabOrder *pOrder = m_aOrders[i];
84 sal_Int32 result = pOrder->compare(record1, record2);
86 if (result) return result;
88 return 0;