update dev300-m58
[ooovba.git] / svx / source / fmcomp / gridcols.cxx
blob561be8ab694cd52cb6f4c912d28b7e84c696444b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gridcols.cxx,v $
10 * $Revision: 1.9 $
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_svx.hxx"
33 #include "gridcols.hxx"
34 #include <tools/debug.hxx>
35 #include <comphelper/types.hxx>
36 #include "fmservs.hxx"
37 #include "fmtools.hxx"
39 //------------------------------------------------------------------------------
40 const ::comphelper::StringSequence& getColumnTypes()
42 static ::comphelper::StringSequence aColumnTypes(10);
43 if (!aColumnTypes.getConstArray()[0].getLength())
45 ::rtl::OUString* pNames = aColumnTypes.getArray();
46 pNames[TYPE_CHECKBOX] = FM_COL_CHECKBOX;
47 pNames[TYPE_COMBOBOX] = FM_COL_COMBOBOX;
48 pNames[TYPE_CURRENCYFIELD] = FM_COL_CURRENCYFIELD;
49 pNames[TYPE_DATEFIELD] = FM_COL_DATEFIELD;
50 pNames[TYPE_FORMATTEDFIELD] = FM_COL_FORMATTEDFIELD;
51 pNames[TYPE_LISTBOX] = FM_COL_LISTBOX;
52 pNames[TYPE_NUMERICFIELD] = FM_COL_NUMERICFIELD;
53 pNames[TYPE_PATTERNFIELD] = FM_COL_PATTERNFIELD;
54 pNames[TYPE_TEXTFIELD] = FM_COL_TEXTFIELD;
55 pNames[TYPE_TIMEFIELD] = FM_COL_TIMEFIELD;
57 return aColumnTypes;
60 //------------------------------------------------------------------------------
61 sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName)
63 const ::rtl::OUString aModelPrefix = ::rtl::OUString::createFromAscii("com.sun.star.form.component.");
64 const ::rtl::OUString aCompatibleModelPrefix = ::rtl::OUString::createFromAscii("stardiv.one.form.component.");
66 sal_Int32 nTypeId = -1;
67 if (aModelName == FM_COMPONENT_EDIT)
68 nTypeId = TYPE_TEXTFIELD;
69 else
71 sal_Int32 nPrefixPos = aModelName.indexOf(aModelPrefix);
72 #ifdef DBG_UTIL
73 sal_Int32 nCompatiblePrefixPos = aModelName.indexOf(aCompatibleModelPrefix);
74 DBG_ASSERT( (nPrefixPos != -1) || (nCompatiblePrefixPos != -1), "::getColumnTypeByModelName() : wrong servivce !");
75 #endif
77 ::rtl::OUString aColumnType = (nPrefixPos != -1)
78 ? aModelName.copy(aModelPrefix.getLength())
79 : aModelName.copy(aCompatibleModelPrefix.getLength());
81 const ::comphelper::StringSequence& rColumnTypes = getColumnTypes();
82 nTypeId = findPos(aColumnType, rColumnTypes);
84 return nTypeId;