merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / querydesign / TableFieldDescription.cxx
blob76f20386ec1d2bd03318427e238c7f7c5dbd9cc9
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: TableFieldDescription.cxx,v $
10 * $Revision: 1.12 $
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_dbaccess.hxx"
34 #ifndef DBAUI_TABLEFIELDDESC_HXX
35 #include "TableFieldDescription.hxx"
36 #endif
37 #ifndef _TOOLS_DEBUG_HXX
38 #include <tools/debug.hxx>
39 #endif
40 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
41 #include <com/sun/star/sdbc/DataType.hpp>
42 #endif
43 #ifndef _COMPHELPER_STREAMSECTION_HXX_
44 #include <comphelper/streamsection.hxx>
45 #endif
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::beans;
50 using namespace comphelper;
51 using namespace dbaui;
53 DBG_NAME(OTableFieldDesc)
54 //==============================================================================
55 OTableFieldDesc::OTableFieldDesc()
56 :m_pTabWindow(0)
57 ,m_eDataType(1000)
58 ,m_eFunctionType( FKT_NONE )
59 ,m_eFieldType(TAB_NORMAL_FIELD)
60 ,m_eOrderDir( ORDER_NONE )
61 ,m_nIndex(0)
62 ,m_nColWidth(0)
63 ,m_nColumnId((sal_uInt16)-1)
64 ,m_bGroupBy(sal_False)
65 ,m_bVisible(sal_False)
67 DBG_CTOR(OTableFieldDesc,NULL);
69 //------------------------------------------------------------------------------
70 OTableFieldDesc::OTableFieldDesc(const OTableFieldDesc& rRS)
71 : ::vos::OReference()
72 ,m_vecCriteria( rRS.m_vecCriteria)
73 ,m_aTableName(rRS.GetTable())
74 ,m_aAliasName(rRS.GetAlias()) // table range
75 ,m_aFieldName(rRS.GetField()) // column
76 ,m_aFieldAlias(rRS.GetFieldAlias()) // column alias
77 ,m_aFunctionName(rRS.GetFunction()) // Funktionsname
78 ,m_pTabWindow(rRS.GetTabWindow())
79 ,m_eDataType(rRS.GetDataType())
80 ,m_eFunctionType( rRS.GetFunctionType() )
81 ,m_eFieldType(rRS.GetFieldType())
82 ,m_eOrderDir(rRS.GetOrderDir())
83 ,m_nIndex(rRS.GetFieldIndex())
84 ,m_nColWidth(rRS.GetColWidth())
85 ,m_nColumnId( rRS.m_nColumnId)
86 ,m_bGroupBy(rRS.IsGroupBy())
87 ,m_bVisible(rRS.IsVisible())
89 DBG_CTOR(OTableFieldDesc,NULL);
92 //------------------------------------------------------------------------------
93 OTableFieldDesc::OTableFieldDesc(const ::rtl::OUString& rT, const ::rtl::OUString& rF )
94 :m_pTabWindow(0)
95 ,m_eFunctionType( FKT_NONE )
96 ,m_eOrderDir( ORDER_NONE )
97 ,m_nColumnId((sal_uInt16)-1)
98 ,m_bGroupBy(sal_False)
99 ,m_bVisible(sal_False)
101 DBG_CTOR(OTableFieldDesc,NULL);
102 SetField( rF ); SetTable( rT );
105 //------------------------------------------------------------------------------
106 OTableFieldDesc::~OTableFieldDesc()
108 DBG_DTOR(OTableFieldDesc,NULL);
111 //------------------------------------------------------------------------------
112 sal_Bool OTableFieldDesc::operator==( const OTableFieldDesc& rDesc )
114 DBG_CHKTHIS(OTableFieldDesc,NULL);
116 return ( m_eOrderDir != rDesc.GetOrderDir() ||
117 m_eDataType != rDesc.GetDataType() ||
118 m_aAliasName != rDesc.GetAlias() ||
119 m_aFunctionName != rDesc.GetFunction() ||
120 m_aFieldName != rDesc.GetField() ||
121 m_aTableName != rDesc.GetTable() ||
122 m_bGroupBy != rDesc.IsGroupBy() ||
123 m_vecCriteria != rDesc.GetCriteria() ||
124 m_bVisible != rDesc.IsVisible() );
128 //------------------------------------------------------------------------------
129 void OTableFieldDesc::SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit)
131 DBG_CHKTHIS(OTableFieldDesc,NULL);
132 if (nIdx < m_vecCriteria.size())
133 m_vecCriteria[nIdx] = rCrit;
134 else
136 for(sal_Int32 i=m_vecCriteria.size();i<nIdx;++i)
137 m_vecCriteria.push_back( ::rtl::OUString());
138 m_vecCriteria.push_back(rCrit);
142 //------------------------------------------------------------------------------
143 ::rtl::OUString OTableFieldDesc::GetCriteria( sal_uInt16 nIdx ) const
145 DBG_CHKTHIS(OTableFieldDesc,NULL);
146 ::rtl::OUString aRetStr;
147 if( nIdx < m_vecCriteria.size())
148 aRetStr = m_vecCriteria[nIdx];
150 return aRetStr;
153 // -----------------------------------------------------------------------------
154 void OTableFieldDesc::Load(const ::com::sun::star::beans::PropertyValue& _rProperty)
156 DBG_CHKTHIS(OTableFieldDesc,NULL);
157 Sequence<PropertyValue> aFieldDesc;
158 _rProperty.Value >>= aFieldDesc;
159 //if ( aFieldDesc.getLength() == 12 )
161 sal_Int32 nCount = aFieldDesc.getLength();
162 for (sal_Int32 nPos = 0; nPos < nCount; ++nPos)
164 if ( aFieldDesc[nPos].Name.equalsAscii("AliasName") )
165 aFieldDesc[nPos].Value >>= m_aAliasName;
166 else if ( aFieldDesc[nPos].Name.equalsAscii("TableName") )
167 aFieldDesc[nPos].Value >>= m_aTableName;
168 else if ( aFieldDesc[nPos].Name.equalsAscii("FieldName") )
169 aFieldDesc[nPos].Value >>= m_aFieldName;
170 else if ( aFieldDesc[nPos].Name.equalsAscii("FieldAlias") )
171 aFieldDesc[nPos].Value >>= m_aFieldAlias;
172 else if ( aFieldDesc[nPos].Name.equalsAscii("FunctionName") )
173 aFieldDesc[nPos].Value >>= m_aFunctionName;
174 else if ( aFieldDesc[nPos].Name.equalsAscii("DataType") )
175 aFieldDesc[nPos].Value >>= m_eDataType;
176 else if ( aFieldDesc[nPos].Name.equalsAscii("FunctionType") )
177 aFieldDesc[nPos].Value >>= m_eFunctionType;
178 else if ( aFieldDesc[nPos].Name.equalsAscii("FieldType") )
180 sal_Int32 nTemp = 0;
181 aFieldDesc[nPos].Value >>= nTemp;
182 m_eFieldType = static_cast<ETableFieldType>(nTemp);
184 else if ( aFieldDesc[nPos].Name.equalsAscii("OrderDir") )
186 sal_Int32 nTemp = 0;
187 aFieldDesc[nPos].Value >>= nTemp;
188 m_eOrderDir = static_cast<EOrderDir>(nTemp);
190 else if ( aFieldDesc[nPos].Name.equalsAscii("ColWidth") )
191 aFieldDesc[nPos].Value >>= m_nColWidth;
192 else if ( aFieldDesc[nPos].Name.equalsAscii("GroupBy") )
193 aFieldDesc[nPos].Value >>= m_bGroupBy;
194 else if ( aFieldDesc[nPos].Name.equalsAscii("Visible") )
195 aFieldDesc[nPos].Value >>= m_bVisible;
199 //------------------------------------------------------------------------------
200 void OTableFieldDesc::Save(::com::sun::star::beans::PropertyValue& _rProperty)
202 DBG_CHKTHIS(OTableFieldDesc,NULL);
205 Sequence<PropertyValue> aFieldDesc(13);
206 sal_Int32 nPos = 0;
207 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AliasName"));
208 aFieldDesc[nPos++].Value <<= m_aAliasName;
209 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableName"));
210 aFieldDesc[nPos++].Value <<= m_aTableName;
211 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldName"));
212 aFieldDesc[nPos++].Value <<= m_aFieldName;
213 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldAlias"));
214 aFieldDesc[nPos++].Value <<= m_aFieldAlias;
215 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FunctionName"));
216 aFieldDesc[nPos++].Value <<= m_aFunctionName;
217 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataType"));
218 aFieldDesc[nPos++].Value <<= m_eDataType;
219 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FunctionType"));
220 aFieldDesc[nPos++].Value <<= (sal_Int32)m_eFunctionType;
221 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldType"));
222 aFieldDesc[nPos++].Value <<= (sal_Int32)m_eFieldType;
223 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OrderDir"));
224 aFieldDesc[nPos++].Value <<= (sal_Int32)m_eOrderDir;
225 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColWidth"));
226 aFieldDesc[nPos++].Value <<= m_nColWidth;
227 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GroupBy"));
228 aFieldDesc[nPos++].Value <<= m_bGroupBy;
229 aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Visible"));
230 aFieldDesc[nPos++].Value <<= m_bVisible;
232 _rProperty.Value <<= aFieldDesc;
234 // -----------------------------------------------------------------------------