update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / kab / kfields.cxx
blob79582dd05de39093dcc5fe399b1501271e927fb4
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 .
20 #include <sal/config.h>
22 #include <osl/diagnose.h>
24 #include "kfields.hxx"
25 #include "resource/common_res.hrc"
26 #include "resource/sharedresources.hxx"
28 using namespace ::connectivity::kab;
29 using namespace ::com::sun::star::sdbc;
31 namespace connectivity
33 namespace kab
36 // return the value of a KDE address book field, given an addressee and a field number
37 QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber)
39 switch (nFieldNumber)
41 case KAB_FIELD_REVISION:
42 return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss");
43 default:
44 ::KABC::Field::List aFields = ::KABC::Field::allFields();
45 return aFields[nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee);
49 // search the KDE address book field number of a given column name
50 sal_uInt32 findKabField(const OUString& columnName) throw(SQLException)
52 QString aQtName;
53 OUString aName;
55 aQtName = KABC::Addressee::revisionLabel();
56 aName = OUString((const sal_Unicode *) aQtName.ucs2());
57 if (columnName == aName)
58 return KAB_FIELD_REVISION;
60 ::KABC::Field::List aFields = ::KABC::Field::allFields();
61 ::KABC::Field::List::iterator aField;
62 sal_uInt32 nResult;
64 for ( aField = aFields.begin(), nResult = KAB_DATA_FIELDS;
65 aField != aFields.end();
66 ++aField, ++nResult)
68 aQtName = (*aField)->label();
69 aName = OUString((const sal_Unicode *) aQtName.ucs2());
71 if (columnName == aName)
72 return nResult;
75 ::connectivity::SharedResources aResources;
76 const OUString sError( aResources.getResourceStringWithSubstitution(
77 STR_INVALID_COLUMNNAME,
78 "$columnname$",columnName
79 ) );
80 ::dbtools::throwGenericSQLException(sError,NULL);
81 // Unreachable:
82 OSL_ASSERT(false);
83 return 0;
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */