1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: kfields.cxx,v $
10 * $Revision: 1.5.56.1 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #include "kfields.hxx"
35 #include "resource/common_res.hrc"
36 #include "resource/sharedresources.hxx"
38 using namespace ::connectivity::kab
;
39 using namespace ::com::sun::star::sdbc
;
41 namespace connectivity
45 // -----------------------------------------------------------------------------
46 // return the value of a KDE address book field, given an addressee and a field number
47 QString
valueOfKabField(const ::KABC::Addressee
&aAddressee
, sal_Int32 nFieldNumber
)
51 case KAB_FIELD_REVISION
:
52 return aAddressee
.revision().toString("yyyy-MM-dd hh:mm:ss");
54 ::KABC::Field::List aFields
= ::KABC::Field::allFields();
55 return aFields
[nFieldNumber
- KAB_DATA_FIELDS
]->value(aAddressee
);
58 // ------------------------------------------------------------------------------
59 // search the KDE address book field number of a given column name
60 sal_uInt32
findKabField(const ::rtl::OUString
& columnName
) throw(SQLException
)
63 ::rtl::OUString aName
;
65 aQtName
= KABC::Addressee::revisionLabel();
66 aName
= ::rtl::OUString((const sal_Unicode
*) aQtName
.ucs2());
67 if (columnName
== aName
)
68 return KAB_FIELD_REVISION
;
70 ::KABC::Field::List aFields
= ::KABC::Field::allFields();
71 ::KABC::Field::List::iterator aField
;
74 for ( aField
= aFields
.begin(), nResult
= KAB_DATA_FIELDS
;
75 aField
!= aFields
.end();
78 aQtName
= (*aField
)->label();
79 aName
= ::rtl::OUString((const sal_Unicode
*) aQtName
.ucs2());
81 if (columnName
== aName
)
85 ::connectivity::SharedResources aResources
;
86 const ::rtl::OUString
sError( aResources
.getResourceStringWithSubstitution(
87 STR_INVALID_COLUMNNAME
,
88 "$columnname$",columnName
90 ::dbtools::throwGenericSQLException(sError
,NULL
);
95 // ------------------------------------------------------------------------------