1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
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 <stringconstants.hxx>
25 #include <connectivity/dbtools.hxx>
26 
27 
28 using namespace connectivity;
29 using namespace connectivity::sdbcx;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::sdbcx;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::container;
35 using namespace ::com::sun::star::lang;
36 using namespace dbaccess;
37 using namespace cppu;
38 
39 
createObject(const OUString & _rName)40 ObjectType OIndexes::createObject(const OUString& _rName)
41 {
42     ObjectType xRet;
43     if ( m_xIndexes.is() && m_xIndexes->hasByName(_rName) )
44         xRet.set(m_xIndexes->getByName(_rName),UNO_QUERY);
45     else
46         xRet = OIndexesHelper::createObject(_rName);
47 
48     return xRet;
49 }
50 
createDescriptor()51 Reference< XPropertySet > OIndexes::createDescriptor()
52 {
53     Reference<XDataDescriptorFactory> xData( m_xIndexes,UNO_QUERY);
54     if(xData.is())
55         return xData->createDataDescriptor();
56     else
57         return OIndexesHelper::createDescriptor();
58 }
59 
60 // XAppend
appendObject(const OUString & _rForName,const Reference<XPropertySet> & descriptor)61 ObjectType OIndexes::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
62 {
63     Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
64     if ( !xData.is() )
65         return OIndexesHelper::appendObject( _rForName, descriptor );
66 
67     xData->appendByDescriptor(descriptor);
68     return createObject( _rForName );
69 }
70 
71 // XDrop
dropObject(sal_Int32 _nPos,const OUString & _sElementName)72 void OIndexes::dropObject(sal_Int32 _nPos, const OUString& _sElementName)
73 {
74     if ( m_xIndexes.is() )
75     {
76         Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
77         if ( xData.is() )
78             xData->dropByName(_sElementName);
79     }
80     else
81         OIndexesHelper::dropObject(_nPos,_sElementName);
82 }
83 
disposing()84 void OIndexes::disposing()
85 {
86     if ( m_xIndexes.is() )
87         clear_NoDispose();
88     else
89         OIndexesHelper::disposing();
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
93