update dev300-m58
[ooovba.git] / connectivity / source / drivers / macab / MacabRecords.hxx
blob8e5d9c3ab2b230548c9ecf5927ca25b6a59d630d
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: MacabRecords.hxx,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 #ifndef _CONNECTIVITY_MACAB_RECORDS_HXX_
32 #define _CONNECTIVITY_MACAB_RECORDS_HXX_
34 #include "MacabRecord.hxx"
35 #include "MacabHeader.hxx"
37 #include <premac.h>
38 #include <Carbon/Carbon.h>
39 #include <AddressBook/ABAddressBookC.h>
40 #include <postmac.h>
41 #include <com/sun/star/util/DateTime.hpp>
43 namespace connectivity
45 namespace macab
47 /* This struct is for converting CF types to AB types (Core Foundation
48 * types to Address Book types).
50 struct lcl_CFType {
51 sal_Int32 cf;
52 sal_Int32 ab;
55 class MacabRecords{
56 protected:
57 /* MacabRecords is, at its core, a table of macabfields, in the
58 * form of a header and a list of objects of type MacabRecord.
59 * It also has a unique name that refers to the name of the table.
61 sal_Int32 recordsSize;
62 sal_Int32 currentRecord;
63 CFStringRef recordType;
64 MacabHeader *header;
65 MacabRecord **records;
66 ABAddressBookRef addressBook;
67 ::rtl::OUString m_sName;
69 /* For converting CF types to AB types */
70 sal_Int32 lcl_CFTypesLength;
71 lcl_CFType *lcl_CFTypes;
73 /* For required properties */
74 CFStringRef *requiredProperties;
75 sal_Int32 numRequiredProperties;
77 private:
78 /* All of the private methods are for creating a MacabHeader or a
79 * MacabRecord. They are used by the initialize method that goes
80 * about filling a MacabRecords using all of the records in the
81 * Mac OS X Address Book.
83 void bootstrap_CF_types();
84 void bootstrap_requiredProperties();
85 MacabHeader *createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const sal_Bool _isPropertyRequired) const;
86 MacabHeader *createHeaderForProperty(const ABPropertyType _propertyType, const CFTypeRef _propertyValue, const CFStringRef _propertyName) const;
87 void manageDuplicateHeaders(macabfield **_headerNames, const sal_Int32 _length) const;
88 ABPropertyType getABTypeFromCFType(const CFTypeID cf_type ) const;
89 void insertPropertyIntoMacabRecord(MacabRecord *_abrecord, const MacabHeader *_header, const ::rtl::OUString _propertyName, const CFTypeRef _propertyValue) const;
90 void insertPropertyIntoMacabRecord(const ABPropertyType _propertyType, MacabRecord *_abrecord, const MacabHeader *_header, const ::rtl::OUString _propertyName, const CFTypeRef _propertyValue) const;
91 public:
92 MacabRecords(const ABAddressBookRef _addressBook, MacabHeader *_header, MacabRecord **_records, sal_Int32 _numRecords);
93 MacabRecords(const MacabRecords *_copy);
94 MacabRecords(const ABAddressBookRef _addressBook);
95 ~MacabRecords();
97 void initialize();
99 void setHeader(MacabHeader *_header);
100 MacabHeader *getHeader() const;
102 void setName(const ::rtl::OUString _sName);
103 ::rtl::OUString getName() const;
105 MacabRecord *insertRecord(MacabRecord *_newRecord, const sal_Int32 _location);
106 void insertRecord(MacabRecord *_newRecord);
107 MacabRecord *getRecord(const sal_Int32 _location) const;
108 void swap(const sal_Int32 _id1, const sal_Int32 _id2);
110 macabfield *getField(const sal_Int32 _recordNumber, const sal_Int32 _columnNumber) const;
111 macabfield *getField(const sal_Int32 _recordNumber, const ::rtl::OUString _columnName) const;
112 sal_Int32 getFieldNumber(const ::rtl::OUString _columnName) const;
114 sal_Int32 size() const;
116 MacabHeader *createHeaderForRecordType(const CFArrayRef _records, const CFStringRef _recordType) const;
117 MacabRecord *createMacabRecord(const ABRecordRef _abrecord, const MacabHeader *_header, const CFStringRef _recordType) const;
119 MacabRecords *begin();
120 sal_Int32 end() const;
121 class iterator{
122 protected:
123 MacabRecords *records;
124 public:
125 sal_Int32 id;
126 void operator= (MacabRecords *_records);
127 iterator();
128 ~iterator();
129 void operator++ ();
130 sal_Bool operator!= (const sal_Int32 i) const;
131 sal_Bool operator== (const sal_Int32 i) const;
132 MacabRecord *operator* () const;
139 #endif // _CONNECTIVITY_MACAB_RECORDS_HXX_