merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / tabledesign / TableFieldControl.cxx
blob150e084e23b5884ba625eed9543a4bbc0d7a5a60
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: TableFieldControl.cxx,v $
10 * $Revision: 1.13 $
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"
33 #ifndef DBAUI_TABLEFIELDCONTROL_HXX
34 #include "TableFieldControl.hxx"
35 #endif
36 #ifndef DBUI_TABLECONTROLLER_HXX
37 #include "TableController.hxx"
38 #endif
39 #ifndef DBAUI_TABLEDESIGNVIEW_HXX
40 #include "TableDesignView.hxx"
41 #endif
42 #ifndef DBAUI_TABLEEDITORCONTROL_HXX
43 #include "TEditControl.hxx"
44 #endif
45 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
46 #include "dbustrings.hrc"
47 #endif
48 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
49 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
53 #endif
54 #ifndef _COMPHELPER_TYPES_HXX_
55 #include <comphelper/types.hxx>
56 #endif
57 #ifndef DBAUI_TYPEINFO_HXX
58 #include "TypeInfo.hxx"
59 #endif
60 #ifndef DBAUI_TOOLS_HXX
61 #include "UITools.hxx"
62 #endif
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::util;
67 using namespace ::com::sun::star::lang;
68 using namespace ::com::sun::star::sdbc;
69 using namespace dbaui;
70 OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
73 //------------------------------------------------------------------
74 void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
76 GetCtrl()->CellModified(nRow,nColId);
78 //------------------------------------------------------------------
79 OTableEditorCtrl* OTableFieldControl::GetCtrl() const
81 OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
82 OSL_ENSURE(pDesignWin,"no view!");
83 return pDesignWin->GetEditorCtrl();
85 //------------------------------------------------------------------
86 sal_Bool OTableFieldControl::IsReadOnly()
88 sal_Bool bRead(GetCtrl()->IsReadOnly());
89 if( !bRead )
91 // Die Spalten einer ::com::sun::star::sdbcx::View können nicht verändert werden
92 Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
93 if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))
94 bRead = sal_True;
95 else
97 ::boost::shared_ptr<OTableRow> pCurRow = GetCtrl()->GetActRow();
98 if( pCurRow )
99 bRead = pCurRow->IsReadOnly();
102 return bRead;
104 //------------------------------------------------------------------
105 void OTableFieldControl::ActivateAggregate( EControlType eType )
107 switch(eType)
109 case tpColumnName:
110 case tpType:
111 break;
112 default:
113 OFieldDescControl::ActivateAggregate(eType);
116 //------------------------------------------------------------------
117 void OTableFieldControl::DeactivateAggregate( EControlType eType )
119 switch(eType)
121 case tpColumnName:
122 case tpType:
123 break;
124 default:
125 OFieldDescControl::DeactivateAggregate(eType);
128 // -----------------------------------------------------------------------------
129 void OTableFieldControl::SetModified(BOOL bModified)
131 GetCtrl()->GetView()->getController().setModified(bModified);
133 // -----------------------------------------------------------------------------
134 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
136 return GetCtrl()->GetView()->getController().getConnection();
138 // -----------------------------------------------------------------------------
139 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
141 Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
142 if(!xCon.is())
143 return NULL;
144 return xCon->getMetaData();
146 // -----------------------------------------------------------------------------
147 Reference< XNumberFormatter > OTableFieldControl::GetFormatter() const
149 return GetCtrl()->GetView()->getController().getNumberFormatter();
151 // -----------------------------------------------------------------------------
152 TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
154 return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
156 // -----------------------------------------------------------------------------
157 const OTypeInfoMap* OTableFieldControl::getTypeInfo() const
159 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
161 // -----------------------------------------------------------------------------
162 Locale OTableFieldControl::GetLocale() const
164 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
166 // -----------------------------------------------------------------------------
167 sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
169 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
171 // -----------------------------------------------------------------------------
172 ::rtl::OUString OTableFieldControl::getAutoIncrementValue() const
174 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
176 // -----------------------------------------------------------------------------