1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_TABLEFIELDCONTROL_HXX
27cdf0e10cSrcweir #include "TableFieldControl.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef DBUI_TABLECONTROLLER_HXX
30cdf0e10cSrcweir #include "TableController.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNVIEW_HXX
33cdf0e10cSrcweir #include "TableDesignView.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef DBAUI_TABLEEDITORCONTROL_HXX
36cdf0e10cSrcweir #include "TEditControl.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
39cdf0e10cSrcweir #include "dbustrings.hrc"
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
42cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
45cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
48cdf0e10cSrcweir #include <comphelper/types.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef DBAUI_TYPEINFO_HXX
51cdf0e10cSrcweir #include "TypeInfo.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX
54cdf0e10cSrcweir #include "UITools.hxx"
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir 
57cdf0e10cSrcweir using namespace ::com::sun::star::uno;
58cdf0e10cSrcweir using namespace ::com::sun::star::beans;
59cdf0e10cSrcweir using namespace ::com::sun::star::util;
60cdf0e10cSrcweir using namespace ::com::sun::star::lang;
61cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
62cdf0e10cSrcweir using namespace dbaui;
OTableFieldControl(Window * pParent,OTableDesignHelpBar * pHelpBar)63cdf0e10cSrcweir OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir //------------------------------------------------------------------
CellModified(long nRow,sal_uInt16 nColId)67cdf0e10cSrcweir void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	GetCtrl()->CellModified(nRow,nColId);
70cdf0e10cSrcweir }
71cdf0e10cSrcweir //------------------------------------------------------------------
GetCtrl() const72cdf0e10cSrcweir OTableEditorCtrl* OTableFieldControl::GetCtrl() const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
75cdf0e10cSrcweir 	OSL_ENSURE(pDesignWin,"no view!");
76cdf0e10cSrcweir 	return pDesignWin->GetEditorCtrl();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir //------------------------------------------------------------------
IsReadOnly()79cdf0e10cSrcweir sal_Bool OTableFieldControl::IsReadOnly()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	sal_Bool bRead(GetCtrl()->IsReadOnly());
82cdf0e10cSrcweir 	if( !bRead )
83cdf0e10cSrcweir 	{
84cdf0e10cSrcweir 		// Die Spalten einer ::com::sun::star::sdbcx::View k�nnen nicht ver�ndert werden
85cdf0e10cSrcweir 		Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
86cdf0e10cSrcweir 		if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))
87cdf0e10cSrcweir 			bRead = sal_True;
88cdf0e10cSrcweir 		else
89cdf0e10cSrcweir 		{
90cdf0e10cSrcweir 			 ::boost::shared_ptr<OTableRow>  pCurRow = GetCtrl()->GetActRow();
91cdf0e10cSrcweir 			if( pCurRow )
92cdf0e10cSrcweir 				bRead = pCurRow->IsReadOnly();
93cdf0e10cSrcweir 		}
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 	return bRead;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir //------------------------------------------------------------------
ActivateAggregate(EControlType eType)98cdf0e10cSrcweir void OTableFieldControl::ActivateAggregate( EControlType eType )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	switch(eType)
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		case tpColumnName:
103cdf0e10cSrcweir 		case tpType:
104cdf0e10cSrcweir 			break;
105cdf0e10cSrcweir 		default:
106cdf0e10cSrcweir 			OFieldDescControl::ActivateAggregate(eType);
107cdf0e10cSrcweir 	}
108cdf0e10cSrcweir }
109cdf0e10cSrcweir //------------------------------------------------------------------
DeactivateAggregate(EControlType eType)110cdf0e10cSrcweir void OTableFieldControl::DeactivateAggregate( EControlType eType )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	switch(eType)
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir 		case tpColumnName:
115cdf0e10cSrcweir 		case tpType:
116cdf0e10cSrcweir 			break;
117cdf0e10cSrcweir 		default:
118cdf0e10cSrcweir 			OFieldDescControl::DeactivateAggregate(eType);
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir }
121cdf0e10cSrcweir // -----------------------------------------------------------------------------
SetModified(sal_Bool bModified)122cdf0e10cSrcweir void OTableFieldControl::SetModified(sal_Bool bModified)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	GetCtrl()->GetView()->getController().setModified(bModified);
125cdf0e10cSrcweir }
126cdf0e10cSrcweir // -----------------------------------------------------------------------------
getConnection()127cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	return GetCtrl()->GetView()->getController().getConnection();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir // -----------------------------------------------------------------------------
getMetaData()132cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
135cdf0e10cSrcweir 	if(!xCon.is())
136cdf0e10cSrcweir 		return NULL;
137cdf0e10cSrcweir 	return xCon->getMetaData();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetFormatter() const140cdf0e10cSrcweir Reference< XNumberFormatter >	OTableFieldControl::GetFormatter() const
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	return GetCtrl()->GetView()->getController().getNumberFormatter();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTypeInfo(sal_Int32 _nPos)145cdf0e10cSrcweir TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
148cdf0e10cSrcweir }
149cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTypeInfo() const150cdf0e10cSrcweir const OTypeInfoMap*	OTableFieldControl::getTypeInfo() const
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
153cdf0e10cSrcweir }
154cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetLocale() const155cdf0e10cSrcweir Locale OTableFieldControl::GetLocale() const
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
158cdf0e10cSrcweir }
159cdf0e10cSrcweir // -----------------------------------------------------------------------------
isAutoIncrementValueEnabled() const160cdf0e10cSrcweir sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAutoIncrementValue() const165cdf0e10cSrcweir ::rtl::OUString OTableFieldControl::getAutoIncrementValue() const
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir // -----------------------------------------------------------------------------
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
174