1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 #ifndef DBACCESS_INDEXES_HXX_
31 #include "CIndexes.hxx"
32 #endif
33 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
34 #include <com/sun/star/sdbc/XRow.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
37 #include <com/sun/star/sdbc/XResultSet.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_
40 #include <com/sun/star/sdbc/IndexType.hpp>
41 #endif
42 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
43 #include "dbastrings.hrc"
44 #endif
45 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
46 #include <connectivity/dbtools.hxx>
47 #endif
48 #ifndef _COMPHELPER_EXTRACT_HXX_
49 #include <comphelper/extract.hxx>
50 #endif
51 #ifndef _TOOLS_DEBUG_HXX
52 #include <tools/debug.hxx>
53 #endif
54 
55 
56 using namespace connectivity;
57 using namespace connectivity::sdbcx;
58 using namespace ::com::sun::star::uno;
59 using namespace ::com::sun::star::beans;
60 using namespace ::com::sun::star::sdbcx;
61 using namespace ::com::sun::star::sdbc;
62 using namespace ::com::sun::star::container;
63 using namespace ::com::sun::star::lang;
64 using namespace dbaccess;
65 using namespace cppu;
66 
67 
68 ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
69 {
70 	ObjectType xRet;
71 	if ( m_xIndexes.is() && m_xIndexes->hasByName(_rName) )
72 		xRet.set(m_xIndexes->getByName(_rName),UNO_QUERY);
73 	else
74 		xRet = OIndexesHelper::createObject(_rName);
75 
76 	return xRet;
77 }
78 // -------------------------------------------------------------------------
79 Reference< XPropertySet > OIndexes::createDescriptor()
80 {
81 	Reference<XDataDescriptorFactory> xData( m_xIndexes,UNO_QUERY);
82 	if(xData.is())
83 		return xData->createDataDescriptor();
84 	else
85 		return OIndexesHelper::createDescriptor();
86 }
87 // -------------------------------------------------------------------------
88 // XAppend
89 ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
90 {
91 	Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
92 	if ( !xData.is() )
93         return OIndexesHelper::appendObject( _rForName, descriptor );
94 
95     xData->appendByDescriptor(descriptor);
96     return createObject( _rForName );
97 }
98 // -------------------------------------------------------------------------
99 // XDrop
100 void OIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
101 {
102 	if ( m_xIndexes.is() )
103 	{
104 		Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
105 		if ( xData.is() )
106 			xData->dropByName(_sElementName);
107 	}
108 	else
109 		OIndexesHelper::dropObject(_nPos,_sElementName);
110 }
111 // -------------------------------------------------------------------------
112 void SAL_CALL OIndexes::disposing(void)
113 {
114 	if ( m_xIndexes.is() )
115 		clear_NoDispose();
116 	else
117 		OIndexesHelper::disposing();
118 }
119 // -----------------------------------------------------------------------------
120 
121 
122 
123 
124