Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / api / CIndexes.cxx
blob0994d91539dc6cfe4edc22076e517014a0eb318f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "CIndexes.hxx"
21 #include <com/sun/star/sdbc/XRow.hpp>
22 #include <com/sun/star/sdbc/XResultSet.hpp>
23 #include <com/sun/star/sdbc/IndexType.hpp>
24 #include "dbastrings.hrc"
25 #include <connectivity/dbtools.hxx>
26 #include <comphelper/extract.hxx>
29 using namespace connectivity;
30 using namespace connectivity::sdbcx;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::beans;
33 using namespace ::com::sun::star::sdbcx;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::lang;
37 using namespace dbaccess;
38 using namespace cppu;
41 ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
43 ObjectType xRet;
44 if ( m_xIndexes.is() && m_xIndexes->hasByName(_rName) )
45 xRet.set(m_xIndexes->getByName(_rName),UNO_QUERY);
46 else
47 xRet = OIndexesHelper::createObject(_rName);
49 return xRet;
52 Reference< XPropertySet > OIndexes::createDescriptor()
54 Reference<XDataDescriptorFactory> xData( m_xIndexes,UNO_QUERY);
55 if(xData.is())
56 return xData->createDataDescriptor();
57 else
58 return OIndexesHelper::createDescriptor();
61 // XAppend
62 ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
64 Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
65 if ( !xData.is() )
66 return OIndexesHelper::appendObject( _rForName, descriptor );
68 xData->appendByDescriptor(descriptor);
69 return createObject( _rForName );
72 // XDrop
73 void OIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
75 if ( m_xIndexes.is() )
77 Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
78 if ( xData.is() )
79 xData->dropByName(_sElementName);
81 else
82 OIndexesHelper::dropObject(_nPos,_sElementName);
85 void SAL_CALL OIndexes::disposing(void)
87 if ( m_xIndexes.is() )
88 clear_NoDispose();
89 else
90 OIndexesHelper::disposing();
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */