diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /connectivity/source/drivers/macab/MacabRecords.hxx | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'connectivity/source/drivers/macab/MacabRecords.hxx')
-rw-r--r-- | connectivity/source/drivers/macab/MacabRecords.hxx | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/connectivity/source/drivers/macab/MacabRecords.hxx b/connectivity/source/drivers/macab/MacabRecords.hxx new file mode 100644 index 000000000..1e7d9975d --- /dev/null +++ b/connectivity/source/drivers/macab/MacabRecords.hxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX + +#include <sal/config.h> + +#include <vector> + +#include "MacabRecord.hxx" +#include "MacabHeader.hxx" + +#include <premac.h> +#include <Carbon/Carbon.h> +#include <AddressBook/ABAddressBookC.h> +#include <postmac.h> +#include <com/sun/star/util/DateTime.hpp> + +namespace connectivity +{ + namespace macab + { + /* This struct is for converting CF types to AB types (Core Foundation + * types to Address Book types). + */ + struct lcl_CFType { + CFTypeID cf; + sal_Int32 ab; + }; + + class MacabRecords{ + protected: + /* MacabRecords is, at its core, a table of macabfields, in the + * form of a header and a list of objects of type MacabRecord. + * It also has a unique name that refers to the name of the table. + */ + sal_Int32 recordsSize; + sal_Int32 currentRecord; + CFStringRef recordType; + MacabHeader *header; + MacabRecord **records; + ABAddressBookRef addressBook; + OUString m_sName; + + /* For converting CF types to AB types */ + std::vector<lcl_CFType> lcl_CFTypes; + + /* For required properties */ + std::vector<CFStringRef> requiredProperties; + + private: + /* All of the private methods are for creating a MacabHeader or a + * MacabRecord. They are used by the initialize method that goes + * about filling a MacabRecords using all of the records in the + * macOS Address Book. + */ + void bootstrap_CF_types(); + void bootstrap_requiredProperties(); + MacabHeader *createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const bool _isPropertyRequired) const; + MacabHeader *createHeaderForProperty(const ABPropertyType _propertyType, const CFTypeRef _propertyValue, const CFStringRef _propertyName) const; + ABPropertyType getABTypeFromCFType(const CFTypeID cf_type ) const; + void insertPropertyIntoMacabRecord(MacabRecord *_abrecord, const MacabHeader *_header, const OUString& _propertyName, const CFTypeRef _propertyValue) const; + void insertPropertyIntoMacabRecord(const ABPropertyType _propertyType, MacabRecord *_abrecord, const MacabHeader *_header, const OUString& _propertyName, const CFTypeRef _propertyValue) const; + public: + MacabRecords(const ABAddressBookRef _addressBook, MacabHeader *_header, MacabRecord **_records, sal_Int32 _numRecords); + explicit MacabRecords(const MacabRecords *_copy); + explicit MacabRecords(const ABAddressBookRef _addressBook); + ~MacabRecords(); + + void initialize(); + + void setHeader(MacabHeader *_header); + MacabHeader *getHeader() const; + + void setName(const OUString& _sName); + OUString const & getName() const; + + MacabRecord *insertRecord(MacabRecord *_newRecord, const sal_Int32 _location); + void insertRecord(MacabRecord *_newRecord); + MacabRecord *getRecord(const sal_Int32 _location) const; + void swap(const sal_Int32 _id1, const sal_Int32 _id2); + + macabfield *getField(const sal_Int32 _recordNumber, const sal_Int32 _columnNumber) const; + macabfield *getField(const sal_Int32 _recordNumber, const OUString& _columnName) const; + sal_Int32 getFieldNumber(const OUString& _columnName) const; + + sal_Int32 size() const; + + MacabHeader *createHeaderForRecordType(const CFArrayRef _records, const CFStringRef _recordType) const; + MacabRecord *createMacabRecord(const ABRecordRef _abrecord, const MacabHeader *_header, const CFStringRef _recordType) const; + + MacabRecords *begin(); + sal_Int32 end() const; + class iterator{ + protected: + MacabRecords *records; + public: + sal_Int32 id; + iterator& operator= (MacabRecords *_records); + iterator(); + ~iterator(); + void operator++ (); + bool operator!= (const sal_Int32 i) const; + bool operator== (const sal_Int32 i) const; + MacabRecord *operator* () const; + }; + + }; + } +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |