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