Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
30 :
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 0 : OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
38 : {
39 0 : }
40 : //------------------------------------------------------------------
41 0 : void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
42 : {
43 0 : GetCtrl()->CellModified(nRow,nColId);
44 0 : }
45 : //------------------------------------------------------------------
46 0 : OTableEditorCtrl* OTableFieldControl::GetCtrl() const
47 : {
48 0 : OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
49 : OSL_ENSURE(pDesignWin,"no view!");
50 0 : return pDesignWin->GetEditorCtrl();
51 : }
52 : //------------------------------------------------------------------
53 0 : sal_Bool OTableFieldControl::IsReadOnly()
54 : {
55 0 : sal_Bool bRead(GetCtrl()->IsReadOnly());
56 0 : if( !bRead )
57 : {
58 : // Die Spalten einer ::com::sun::star::sdbcx::View können nicht verändert werden
59 0 : Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
60 0 : if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")))
61 0 : bRead = sal_True;
62 : else
63 : {
64 0 : ::boost::shared_ptr<OTableRow> pCurRow = GetCtrl()->GetActRow();
65 0 : if( pCurRow )
66 0 : bRead = pCurRow->IsReadOnly();
67 0 : }
68 : }
69 0 : return bRead;
70 : }
71 : //------------------------------------------------------------------
72 0 : void OTableFieldControl::ActivateAggregate( EControlType eType )
73 : {
74 0 : switch(eType)
75 : {
76 : case tpColumnName:
77 : case tpType:
78 0 : break;
79 : default:
80 0 : OFieldDescControl::ActivateAggregate(eType);
81 : }
82 0 : }
83 : //------------------------------------------------------------------
84 0 : void OTableFieldControl::DeactivateAggregate( EControlType eType )
85 : {
86 0 : switch(eType)
87 : {
88 : case tpColumnName:
89 : case tpType:
90 0 : break;
91 : default:
92 0 : OFieldDescControl::DeactivateAggregate(eType);
93 : }
94 0 : }
95 : // -----------------------------------------------------------------------------
96 0 : void OTableFieldControl::SetModified(sal_Bool bModified)
97 : {
98 0 : GetCtrl()->GetView()->getController().setModified(bModified);
99 0 : }
100 : // -----------------------------------------------------------------------------
101 0 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
102 : {
103 0 : return GetCtrl()->GetView()->getController().getConnection();
104 : }
105 : // -----------------------------------------------------------------------------
106 0 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
107 : {
108 0 : Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
109 0 : if(!xCon.is())
110 0 : return NULL;
111 0 : return xCon->getMetaData();
112 : }
113 : // -----------------------------------------------------------------------------
114 0 : Reference< XNumberFormatter > OTableFieldControl::GetFormatter() const
115 : {
116 0 : return GetCtrl()->GetView()->getController().getNumberFormatter();
117 : }
118 : // -----------------------------------------------------------------------------
119 0 : TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
120 : {
121 0 : return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
122 : }
123 : // -----------------------------------------------------------------------------
124 0 : const OTypeInfoMap* OTableFieldControl::getTypeInfo() const
125 : {
126 0 : return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
127 : }
128 : // -----------------------------------------------------------------------------
129 0 : Locale OTableFieldControl::GetLocale() const
130 : {
131 0 : return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
132 : }
133 : // -----------------------------------------------------------------------------
134 0 : sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
135 : {
136 0 : return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
137 : }
138 : // -----------------------------------------------------------------------------
139 0 : ::rtl::OUString OTableFieldControl::getAutoIncrementValue() const
140 : {
141 0 : return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
142 : }
143 : // -----------------------------------------------------------------------------
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|