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: DColumns.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_connectivity.hxx"
33 #include "dbase/DColumns.hxx"
34 #include "dbase/DTable.hxx"
35 #include "connectivity/sdbcx/VColumn.hxx"
36 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
37 #include <comphelper/property.hxx>
39 using namespace connectivity::dbase
;
40 using namespace connectivity
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::beans
;
43 using namespace ::com::sun::star::lang
;
44 using namespace ::com::sun::star::sdbcx
;
45 using namespace ::com::sun::star::sdbc
;
46 using namespace ::com::sun::star::container
;
48 typedef file::OColumns ODbaseColumns_BASE
;
49 sdbcx::ObjectType
ODbaseColumns::createObject(const ::rtl::OUString
& _rName
)
52 ODbaseTable
* pTable
= (ODbaseTable
*)m_pTable
;
54 // Reference< XFastPropertySet> xCol(pTable->getColumns()[_rName],UNO_QUERY);
55 ::vos::ORef
<OSQLColumns
> aCols
= pTable
->getTableColumns();
56 OSQLColumns::Vector::const_iterator aIter
= find(aCols
->get().begin(),aCols
->get().end(),_rName
,::comphelper::UStringMixEqual(isCaseSensitive()));
58 sdbcx::ObjectType xRet
;
59 if(aIter
!= aCols
->get().end())
60 xRet
= sdbcx::ObjectType(*aIter
,UNO_QUERY
);
64 // -------------------------------------------------------------------------
65 void ODbaseColumns::impl_refresh() throw(RuntimeException
)
67 m_pTable
->refreshColumns();
69 // -------------------------------------------------------------------------
70 Reference
< XPropertySet
> ODbaseColumns::createDescriptor()
72 return new sdbcx::OColumn(isCaseSensitive());
74 // -----------------------------------------------------------------------------
75 // -------------------------------------------------------------------------
77 sdbcx::ObjectType
ODbaseColumns::appendObject( const ::rtl::OUString
& _rForName
, const Reference
< XPropertySet
>& descriptor
)
79 if ( m_pTable
->isNew() )
80 return cloneDescriptor( descriptor
);
82 m_pTable
->addColumn( descriptor
);
83 return createObject( _rForName
);
85 // -----------------------------------------------------------------------------
86 // -------------------------------------------------------------------------
88 void ODbaseColumns::dropObject(sal_Int32 _nPos
,const ::rtl::OUString
/*_sElementName*/)
90 if(!m_pTable
->isNew())
91 m_pTable
->dropColumn(_nPos
);
93 // -----------------------------------------------------------------------------