xref: /trunk/main/dbaccess/source/ui/tabledesign/TableFieldControl.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 #ifndef DBAUI_TABLEFIELDCONTROL_HXX
31 #include "TableFieldControl.hxx"
32 #endif
33 #ifndef DBUI_TABLECONTROLLER_HXX
34 #include "TableController.hxx"
35 #endif
36 #ifndef DBAUI_TABLEDESIGNVIEW_HXX
37 #include "TableDesignView.hxx"
38 #endif
39 #ifndef DBAUI_TABLEEDITORCONTROL_HXX
40 #include "TEditControl.hxx"
41 #endif
42 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
43 #include "dbustrings.hrc"
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
46 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
49 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 #endif
51 #ifndef _COMPHELPER_TYPES_HXX_
52 #include <comphelper/types.hxx>
53 #endif
54 #ifndef DBAUI_TYPEINFO_HXX
55 #include "TypeInfo.hxx"
56 #endif
57 #ifndef DBAUI_TOOLS_HXX
58 #include "UITools.hxx"
59 #endif
60 
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::beans;
63 using namespace ::com::sun::star::util;
64 using namespace ::com::sun::star::lang;
65 using namespace ::com::sun::star::sdbc;
66 using namespace dbaui;
67 OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
68 {
69 }
70 //------------------------------------------------------------------
71 void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
72 {
73     GetCtrl()->CellModified(nRow,nColId);
74 }
75 //------------------------------------------------------------------
76 OTableEditorCtrl* OTableFieldControl::GetCtrl() const
77 {
78     OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
79     OSL_ENSURE(pDesignWin,"no view!");
80     return pDesignWin->GetEditorCtrl();
81 }
82 //------------------------------------------------------------------
83 sal_Bool OTableFieldControl::IsReadOnly()
84 {
85     sal_Bool bRead(GetCtrl()->IsReadOnly());
86     if( !bRead )
87     {
88         // Die Spalten einer ::com::sun::star::sdbcx::View k�nnen nicht ver�ndert werden
89         Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
90         if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW"))
91             bRead = sal_True;
92         else
93         {
94              ::boost::shared_ptr<OTableRow>  pCurRow = GetCtrl()->GetActRow();
95             if( pCurRow )
96                 bRead = pCurRow->IsReadOnly();
97         }
98     }
99     return bRead;
100 }
101 //------------------------------------------------------------------
102 void OTableFieldControl::ActivateAggregate( EControlType eType )
103 {
104     switch(eType)
105     {
106         case tpColumnName:
107         case tpType:
108             break;
109         default:
110             OFieldDescControl::ActivateAggregate(eType);
111     }
112 }
113 //------------------------------------------------------------------
114 void OTableFieldControl::DeactivateAggregate( EControlType eType )
115 {
116     switch(eType)
117     {
118         case tpColumnName:
119         case tpType:
120             break;
121         default:
122             OFieldDescControl::DeactivateAggregate(eType);
123     }
124 }
125 // -----------------------------------------------------------------------------
126 void OTableFieldControl::SetModified(sal_Bool bModified)
127 {
128     GetCtrl()->GetView()->getController().setModified(bModified);
129 }
130 // -----------------------------------------------------------------------------
131 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
132 {
133     return GetCtrl()->GetView()->getController().getConnection();
134 }
135 // -----------------------------------------------------------------------------
136 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
137 {
138     Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
139     if(!xCon.is())
140         return NULL;
141     return xCon->getMetaData();
142 }
143 // -----------------------------------------------------------------------------
144 Reference< XNumberFormatter >   OTableFieldControl::GetFormatter() const
145 {
146     return GetCtrl()->GetView()->getController().getNumberFormatter();
147 }
148 // -----------------------------------------------------------------------------
149 TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
150 {
151     return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
152 }
153 // -----------------------------------------------------------------------------
154 const OTypeInfoMap* OTableFieldControl::getTypeInfo() const
155 {
156     return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
157 }
158 // -----------------------------------------------------------------------------
159 Locale OTableFieldControl::GetLocale() const
160 {
161     return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
162 }
163 // -----------------------------------------------------------------------------
164 sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
165 {
166     return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
167 }
168 // -----------------------------------------------------------------------------
169 ::rtl::OUString OTableFieldControl::getAutoIncrementValue() const
170 {
171     return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
172 }
173 // -----------------------------------------------------------------------------
174 
175 
176 
177 
178