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 .
21 #include "kfields.hxx"
22 #include "resource/common_res.hrc"
23 #include "resource/sharedresources.hxx"
25 using namespace ::connectivity::kab
;
26 using namespace ::com::sun::star::sdbc
;
28 namespace connectivity
33 // return the value of a KDE address book field, given an addressee and a field number
34 QString
valueOfKabField(const ::KABC::Addressee
&aAddressee
, sal_Int32 nFieldNumber
)
38 case KAB_FIELD_REVISION
:
39 return aAddressee
.revision().toString("yyyy-MM-dd hh:mm:ss");
41 ::KABC::Field::List aFields
= ::KABC::Field::allFields();
42 return aFields
[nFieldNumber
- KAB_DATA_FIELDS
]->value(aAddressee
);
46 // search the KDE address book field number of a given column name
47 sal_uInt32
findKabField(const OUString
& columnName
) throw(SQLException
)
52 aQtName
= KABC::Addressee::revisionLabel();
53 aName
= OUString((const sal_Unicode
*) aQtName
.ucs2());
54 if (columnName
== aName
)
55 return KAB_FIELD_REVISION
;
57 ::KABC::Field::List aFields
= ::KABC::Field::allFields();
58 ::KABC::Field::List::iterator aField
;
61 for ( aField
= aFields
.begin(), nResult
= KAB_DATA_FIELDS
;
62 aField
!= aFields
.end();
65 aQtName
= (*aField
)->label();
66 aName
= OUString((const sal_Unicode
*) aQtName
.ucs2());
68 if (columnName
== aName
)
72 ::connectivity::SharedResources aResources
;
73 const OUString
sError( aResources
.getResourceStringWithSubstitution(
74 STR_INVALID_COLUMNNAME
,
75 "$columnname$",columnName
77 ::dbtools::throwGenericSQLException(sError
,NULL
);
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */