1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableFieldControl.cxx,v $
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"
36 #ifndef DBUI_TABLECONTROLLER_HXX
37 #include "TableController.hxx"
39 #ifndef DBAUI_TABLEDESIGNVIEW_HXX
40 #include "TableDesignView.hxx"
42 #ifndef DBAUI_TABLEEDITORCONTROL_HXX
43 #include "TEditControl.hxx"
45 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
46 #include "dbustrings.hrc"
48 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
49 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
51 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
54 #ifndef _COMPHELPER_TYPES_HXX_
55 #include <comphelper/types.hxx>
57 #ifndef DBAUI_TYPEINFO_HXX
58 #include "TypeInfo.hxx"
60 #ifndef DBAUI_TOOLS_HXX
61 #include "UITools.hxx"
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());
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"))
97 ::boost::shared_ptr
<OTableRow
> pCurRow
= GetCtrl()->GetActRow();
99 bRead
= pCurRow
->IsReadOnly();
104 //------------------------------------------------------------------
105 void OTableFieldControl::ActivateAggregate( EControlType eType
)
113 OFieldDescControl::ActivateAggregate(eType
);
116 //------------------------------------------------------------------
117 void OTableFieldControl::DeactivateAggregate( EControlType eType
)
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();
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 // -----------------------------------------------------------------------------