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/.
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 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX
23 #include "MacabRecord.hxx"
24 #include "MacabHeader.hxx"
27 #include <Carbon/Carbon.h>
28 #include <AddressBook/ABAddressBookC.h>
30 #include <com/sun/star/util/DateTime.hpp>
32 namespace connectivity
36 /* This struct is for converting CF types to AB types (Core Foundation
37 * types to Address Book types).
46 /* MacabRecords is, at its core, a table of macabfields, in the
47 * form of a header and a list of objects of type MacabRecord.
48 * It also has a unique name that refers to the name of the table.
50 sal_Int32 recordsSize
;
51 sal_Int32 currentRecord
;
52 CFStringRef recordType
;
54 MacabRecord
**records
;
55 ABAddressBookRef addressBook
;
58 /* For converting CF types to AB types */
59 sal_Int32 lcl_CFTypesLength
;
60 lcl_CFType
*lcl_CFTypes
;
62 /* For required properties */
63 CFStringRef
*requiredProperties
;
64 sal_Int32 numRequiredProperties
;
67 /* All of the private methods are for creating a MacabHeader or a
68 * MacabRecord. They are used by the initialize method that goes
69 * about filling a MacabRecords using all of the records in the
70 * Mac OS X Address Book.
72 void bootstrap_CF_types();
73 void bootstrap_requiredProperties();
74 MacabHeader
*createHeaderForProperty(const ABRecordRef _record
, const CFStringRef _propertyName
, const CFStringRef _recordType
, const sal_Bool _isPropertyRequired
) const;
75 MacabHeader
*createHeaderForProperty(const ABPropertyType _propertyType
, const CFTypeRef _propertyValue
, const CFStringRef _propertyName
) const;
76 void manageDuplicateHeaders(macabfield
**_headerNames
, const sal_Int32 _length
) const;
77 ABPropertyType
getABTypeFromCFType(const CFTypeID cf_type
) const;
78 void insertPropertyIntoMacabRecord(MacabRecord
*_abrecord
, const MacabHeader
*_header
, const OUString
& _propertyName
, const CFTypeRef _propertyValue
) const;
79 void insertPropertyIntoMacabRecord(const ABPropertyType _propertyType
, MacabRecord
*_abrecord
, const MacabHeader
*_header
, const OUString
& _propertyName
, const CFTypeRef _propertyValue
) const;
81 MacabRecords(const ABAddressBookRef _addressBook
, MacabHeader
*_header
, MacabRecord
**_records
, sal_Int32 _numRecords
);
82 MacabRecords(const MacabRecords
*_copy
);
83 MacabRecords(const ABAddressBookRef _addressBook
);
88 void setHeader(MacabHeader
*_header
);
89 MacabHeader
*getHeader() const;
91 void setName(const OUString
& _sName
);
92 OUString
getName() const;
94 MacabRecord
*insertRecord(MacabRecord
*_newRecord
, const sal_Int32 _location
);
95 void insertRecord(MacabRecord
*_newRecord
);
96 MacabRecord
*getRecord(const sal_Int32 _location
) const;
97 void swap(const sal_Int32 _id1
, const sal_Int32 _id2
);
99 macabfield
*getField(const sal_Int32 _recordNumber
, const sal_Int32 _columnNumber
) const;
100 macabfield
*getField(const sal_Int32 _recordNumber
, const OUString
& _columnName
) const;
101 sal_Int32
getFieldNumber(const OUString
& _columnName
) const;
103 sal_Int32
size() const;
105 MacabHeader
*createHeaderForRecordType(const CFArrayRef _records
, const CFStringRef _recordType
) const;
106 MacabRecord
*createMacabRecord(const ABRecordRef _abrecord
, const MacabHeader
*_header
, const CFStringRef _recordType
) const;
108 MacabRecords
*begin();
109 sal_Int32
end() const;
112 MacabRecords
*records
;
115 iterator
& operator= (MacabRecords
*_records
);
119 sal_Bool
operator!= (const sal_Int32 i
) const;
120 sal_Bool
operator== (const sal_Int32 i
) const;
121 MacabRecord
*operator* () const;
128 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */