update credits
[LibreOffice.git] / dbaccess / source / ui / tabledesign / TableFieldControl.cxx
blob457035c43cdb4accabc7217e4172f061ea690668
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "TableFieldControl.hxx"
21 #include "TableController.hxx"
22 #include "TableDesignView.hxx"
23 #include "TEditControl.hxx"
24 #include "dbustrings.hrc"
25 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <comphelper/types.hxx>
28 #include "TypeInfo.hxx"
29 #include "UITools.hxx"
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::beans;
33 using namespace ::com::sun::star::util;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::sdbc;
36 using namespace dbaui;
37 OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
40 //------------------------------------------------------------------
41 void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
43 GetCtrl()->CellModified(nRow,nColId);
45 //------------------------------------------------------------------
46 OTableEditorCtrl* OTableFieldControl::GetCtrl() const
48 OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
49 OSL_ENSURE(pDesignWin,"no view!");
50 return pDesignWin->GetEditorCtrl();
52 //------------------------------------------------------------------
53 sal_Bool OTableFieldControl::IsReadOnly()
55 sal_Bool bRead(GetCtrl()->IsReadOnly());
56 if( !bRead )
58 // Die Spalten einer ::com::sun::star::sdbcx::View können nicht verändert werden
59 Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
60 if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == OUString("VIEW"))
61 bRead = sal_True;
62 else
64 ::boost::shared_ptr<OTableRow> pCurRow = GetCtrl()->GetActRow();
65 if( pCurRow )
66 bRead = pCurRow->IsReadOnly();
69 return bRead;
71 //------------------------------------------------------------------
72 void OTableFieldControl::ActivateAggregate( EControlType eType )
74 switch(eType)
76 case tpColumnName:
77 case tpType:
78 break;
79 default:
80 OFieldDescControl::ActivateAggregate(eType);
83 //------------------------------------------------------------------
84 void OTableFieldControl::DeactivateAggregate( EControlType eType )
86 switch(eType)
88 case tpColumnName:
89 case tpType:
90 break;
91 default:
92 OFieldDescControl::DeactivateAggregate(eType);
95 // -----------------------------------------------------------------------------
96 void OTableFieldControl::SetModified(sal_Bool bModified)
98 GetCtrl()->GetView()->getController().setModified(bModified);
100 // -----------------------------------------------------------------------------
101 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
103 return GetCtrl()->GetView()->getController().getConnection();
105 // -----------------------------------------------------------------------------
106 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
108 Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
109 if(!xCon.is())
110 return NULL;
111 return xCon->getMetaData();
113 // -----------------------------------------------------------------------------
114 Reference< XNumberFormatter > OTableFieldControl::GetFormatter() const
116 return GetCtrl()->GetView()->getController().getNumberFormatter();
118 // -----------------------------------------------------------------------------
119 TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
121 return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
123 // -----------------------------------------------------------------------------
124 const OTypeInfoMap* OTableFieldControl::getTypeInfo() const
126 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
128 // -----------------------------------------------------------------------------
129 Locale OTableFieldControl::GetLocale() const
131 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
133 // -----------------------------------------------------------------------------
134 sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
136 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
138 // -----------------------------------------------------------------------------
139 OUString OTableFieldControl::getAutoIncrementValue() const
141 return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
143 // -----------------------------------------------------------------------------
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */