Update ooo320-m1
[ooovba.git] / dbaccess / source / core / api / CIndexes.cxx
blob94362567dad9eeb111e58ce4cb81af5287c7c6f0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CIndexes.cxx,v $
10 * $Revision: 1.19 $
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_dbaccess.hxx"
33 #ifndef DBACCESS_INDEXES_HXX_
34 #include "CIndexes.hxx"
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
37 #include <com/sun/star/sdbc/XRow.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
40 #include <com/sun/star/sdbc/XResultSet.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_
43 #include <com/sun/star/sdbc/IndexType.hpp>
44 #endif
45 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
46 #include "dbastrings.hrc"
47 #endif
48 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
49 #include <connectivity/dbtools.hxx>
50 #endif
51 #ifndef _COMPHELPER_EXTRACT_HXX_
52 #include <comphelper/extract.hxx>
53 #endif
54 #ifndef _TOOLS_DEBUG_HXX
55 #include <tools/debug.hxx>
56 #endif
59 using namespace connectivity;
60 using namespace connectivity::sdbcx;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::beans;
63 using namespace ::com::sun::star::sdbcx;
64 using namespace ::com::sun::star::sdbc;
65 using namespace ::com::sun::star::container;
66 using namespace ::com::sun::star::lang;
67 using namespace dbaccess;
68 using namespace cppu;
71 ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
73 ObjectType xRet;
74 if ( m_xIndexes.is() && m_xIndexes->hasByName(_rName) )
75 xRet.set(m_xIndexes->getByName(_rName),UNO_QUERY);
76 else
77 xRet = OIndexesHelper::createObject(_rName);
79 return xRet;
81 // -------------------------------------------------------------------------
82 Reference< XPropertySet > OIndexes::createDescriptor()
84 Reference<XDataDescriptorFactory> xData( m_xIndexes,UNO_QUERY);
85 if(xData.is())
86 return xData->createDataDescriptor();
87 else
88 return OIndexesHelper::createDescriptor();
90 // -------------------------------------------------------------------------
91 // XAppend
92 ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
94 Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
95 if ( !xData.is() )
96 return OIndexesHelper::appendObject( _rForName, descriptor );
98 xData->appendByDescriptor(descriptor);
99 return createObject( _rForName );
101 // -------------------------------------------------------------------------
102 // XDrop
103 void OIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
105 if ( m_xIndexes.is() )
107 Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
108 if ( xData.is() )
109 xData->dropByName(_sElementName);
111 else
112 OIndexesHelper::dropObject(_nPos,_sElementName);
114 // -------------------------------------------------------------------------
115 void SAL_CALL OIndexes::disposing(void)
117 if ( m_xIndexes.is() )
118 clear_NoDispose();
119 else
120 OIndexesHelper::disposing();
122 // -----------------------------------------------------------------------------