1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "dbase/DColumns.hxx"
27 #include "dbase/DTable.hxx"
28 #include "connectivity/sdbcx/VColumn.hxx"
29 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
30 #include <comphelper/property.hxx>
31
32 using namespace connectivity::dbase;
33 using namespace connectivity;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::sdbc;
39 using namespace ::com::sun::star::container;
40
41 typedef file::OColumns ODbaseColumns_BASE;
createObject(const::rtl::OUString & _rName)42 sdbcx::ObjectType ODbaseColumns::createObject(const ::rtl::OUString& _rName)
43 {
44
45 ODbaseTable* pTable = (ODbaseTable*)m_pTable;
46
47 // Reference< XFastPropertySet> xCol(pTable->getColumns()[_rName],UNO_QUERY);
48 ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
49 OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
50
51 sdbcx::ObjectType xRet;
52 if(aIter != aCols->get().end())
53 xRet = sdbcx::ObjectType(*aIter,UNO_QUERY);
54 return xRet;
55 }
56
57 // -------------------------------------------------------------------------
impl_refresh()58 void ODbaseColumns::impl_refresh() throw(RuntimeException)
59 {
60 m_pTable->refreshColumns();
61 }
62 // -------------------------------------------------------------------------
createDescriptor()63 Reference< XPropertySet > ODbaseColumns::createDescriptor()
64 {
65 return new sdbcx::OColumn(isCaseSensitive());
66 }
67 // -----------------------------------------------------------------------------
68 // -------------------------------------------------------------------------
69 // XAppend
appendObject(const::rtl::OUString & _rForName,const Reference<XPropertySet> & descriptor)70 sdbcx::ObjectType ODbaseColumns::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
71 {
72 if ( m_pTable->isNew() )
73 return cloneDescriptor( descriptor );
74
75 m_pTable->addColumn( descriptor );
76 return createObject( _rForName );
77 }
78 // -----------------------------------------------------------------------------
79 // -------------------------------------------------------------------------
80 // XDrop
dropObject(sal_Int32 _nPos,const::rtl::OUString)81 void ODbaseColumns::dropObject(sal_Int32 _nPos,const ::rtl::OUString /*_sElementName*/)
82 {
83 if(!m_pTable->isNew())
84 m_pTable->dropColumn(_nPos);
85 }
86 // -----------------------------------------------------------------------------
87
88