1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "gridcols.hxx"
30 #include <tools/debug.hxx>
31 #include <comphelper/types.hxx>
32 #include "fmservs.hxx"
33 #include "svx/fmtools.hxx"
34 using namespace ::com::sun::star::uno
;
36 //------------------------------------------------------------------------------
37 const ::comphelper::StringSequence
& getColumnTypes()
39 static ::comphelper::StringSequence
aColumnTypes(10);
40 if (aColumnTypes
.getConstArray()[0].isEmpty())
42 ::rtl::OUString
* pNames
= aColumnTypes
.getArray();
43 pNames
[TYPE_CHECKBOX
] = FM_COL_CHECKBOX
;
44 pNames
[TYPE_COMBOBOX
] = FM_COL_COMBOBOX
;
45 pNames
[TYPE_CURRENCYFIELD
] = FM_COL_CURRENCYFIELD
;
46 pNames
[TYPE_DATEFIELD
] = FM_COL_DATEFIELD
;
47 pNames
[TYPE_FORMATTEDFIELD
] = FM_COL_FORMATTEDFIELD
;
48 pNames
[TYPE_LISTBOX
] = FM_COL_LISTBOX
;
49 pNames
[TYPE_NUMERICFIELD
] = FM_COL_NUMERICFIELD
;
50 pNames
[TYPE_PATTERNFIELD
] = FM_COL_PATTERNFIELD
;
51 pNames
[TYPE_TEXTFIELD
] = FM_COL_TEXTFIELD
;
52 pNames
[TYPE_TIMEFIELD
] = FM_COL_TIMEFIELD
;
57 //------------------------------------------------------------------
58 // Vergleichen von PropertyInfo
59 extern "C" int SAL_CALL
NameCompare(const void* pFirst
, const void* pSecond
)
61 return ((::rtl::OUString
*)pFirst
)->compareTo(*(::rtl::OUString
*)pSecond
);
66 //------------------------------------------------------------------------------
67 sal_Int32
lcl_findPos(const ::rtl::OUString
& aStr
, const Sequence
< ::rtl::OUString
>& rList
)
69 const ::rtl::OUString
* pStrList
= rList
.getConstArray();
70 ::rtl::OUString
* pResult
= (::rtl::OUString
*) bsearch(&aStr
, (void*)pStrList
, rList
.getLength(), sizeof(::rtl::OUString
),
74 return (pResult
- pStrList
);
80 //------------------------------------------------------------------------------
81 sal_Int32
getColumnTypeByModelName(const ::rtl::OUString
& aModelName
)
83 const ::rtl::OUString
aModelPrefix(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component."));
84 const ::rtl::OUString
aCompatibleModelPrefix(RTL_CONSTASCII_USTRINGPARAM("stardiv.one.form.component."));
86 sal_Int32 nTypeId
= -1;
87 if (aModelName
== FM_COMPONENT_EDIT
)
88 nTypeId
= TYPE_TEXTFIELD
;
91 sal_Int32 nPrefixPos
= aModelName
.indexOf(aModelPrefix
);
93 sal_Int32 nCompatiblePrefixPos
= aModelName
.indexOf(aCompatibleModelPrefix
);
94 DBG_ASSERT( (nPrefixPos
!= -1) || (nCompatiblePrefixPos
!= -1), "::getColumnTypeByModelName() : wrong servivce !");
97 ::rtl::OUString aColumnType
= (nPrefixPos
!= -1)
98 ? aModelName
.copy(aModelPrefix
.getLength())
99 : aModelName
.copy(aCompatibleModelPrefix
.getLength());
101 const ::comphelper::StringSequence
& rColumnTypes
= getColumnTypes();
102 nTypeId
= lcl_findPos(aColumnType
, rColumnTypes
);
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */