xref: /trunk/main/dbaccess/source/core/api/CIndexes.cxx (revision 96de5490)
1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBACCESS_INDEXES_HXX_
27cdf0e10cSrcweir #include "CIndexes.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
33cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_
36cdf0e10cSrcweir #include <com/sun/star/sdbc/IndexType.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
39cdf0e10cSrcweir #include "dbastrings.hrc"
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_
42cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_
45cdf0e10cSrcweir #include <comphelper/extract.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
48cdf0e10cSrcweir #include <tools/debug.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace connectivity;
53cdf0e10cSrcweir using namespace connectivity::sdbcx;
54cdf0e10cSrcweir using namespace ::com::sun::star::uno;
55cdf0e10cSrcweir using namespace ::com::sun::star::beans;
56cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
57cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
58cdf0e10cSrcweir using namespace ::com::sun::star::container;
59cdf0e10cSrcweir using namespace ::com::sun::star::lang;
60cdf0e10cSrcweir using namespace dbaccess;
61cdf0e10cSrcweir using namespace cppu;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
createObject(const::rtl::OUString & _rName)64cdf0e10cSrcweir ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	ObjectType xRet;
67cdf0e10cSrcweir 	if ( m_xIndexes.is() && m_xIndexes->hasByName(_rName) )
68cdf0e10cSrcweir 		xRet.set(m_xIndexes->getByName(_rName),UNO_QUERY);
69cdf0e10cSrcweir 	else
70cdf0e10cSrcweir 		xRet = OIndexesHelper::createObject(_rName);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	return xRet;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir // -------------------------------------------------------------------------
createDescriptor()75cdf0e10cSrcweir Reference< XPropertySet > OIndexes::createDescriptor()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	Reference<XDataDescriptorFactory> xData( m_xIndexes,UNO_QUERY);
78cdf0e10cSrcweir 	if(xData.is())
79cdf0e10cSrcweir 		return xData->createDataDescriptor();
80cdf0e10cSrcweir 	else
81cdf0e10cSrcweir 		return OIndexesHelper::createDescriptor();
82cdf0e10cSrcweir }
83cdf0e10cSrcweir // -------------------------------------------------------------------------
84cdf0e10cSrcweir // XAppend
appendObject(const::rtl::OUString & _rForName,const Reference<XPropertySet> & descriptor)85cdf0e10cSrcweir ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
88cdf0e10cSrcweir 	if ( !xData.is() )
89cdf0e10cSrcweir         return OIndexesHelper::appendObject( _rForName, descriptor );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     xData->appendByDescriptor(descriptor);
92cdf0e10cSrcweir     return createObject( _rForName );
93cdf0e10cSrcweir }
94cdf0e10cSrcweir // -------------------------------------------------------------------------
95cdf0e10cSrcweir // XDrop
dropObject(sal_Int32 _nPos,const::rtl::OUString _sElementName)96cdf0e10cSrcweir void OIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	if ( m_xIndexes.is() )
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
101cdf0e10cSrcweir 		if ( xData.is() )
102cdf0e10cSrcweir 			xData->dropByName(_sElementName);
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 	else
105cdf0e10cSrcweir 		OIndexesHelper::dropObject(_nPos,_sElementName);
106cdf0e10cSrcweir }
107cdf0e10cSrcweir // -------------------------------------------------------------------------
disposing(void)108cdf0e10cSrcweir void SAL_CALL OIndexes::disposing(void)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	if ( m_xIndexes.is() )
111cdf0e10cSrcweir 		clear_NoDispose();
112cdf0e10cSrcweir 	else
113cdf0e10cSrcweir 		OIndexesHelper::disposing();
114cdf0e10cSrcweir }
115cdf0e10cSrcweir // -----------------------------------------------------------------------------
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120