1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DCode.cxx,v $
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_connectivity.hxx"
33 #include "dbase/DCode.hxx"
34 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
35 #include "dbase/DIndex.hxx"
36 #include "dbase/DIndexIter.hxx"
39 using namespace connectivity::dbase
;
40 using namespace connectivity::file
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::beans
;
43 using namespace ::com::sun::star::sdbcx
;
44 using namespace ::com::sun::star::lang
;
45 using namespace ::com::sun::star::container
;
47 TYPEINIT1(OFILEOperandAttr
, OOperandAttr
);
48 // -----------------------------------------------------------------------------
49 OOperandAttr
* OFILEAnalyzer::createOperandAttr(sal_Int32 _nPos
,
50 const Reference
< XPropertySet
>& _xCol
,
51 const Reference
< XNameAccess
>& _xIndexes
)
53 return new OFILEOperandAttr((sal_uInt16
)_nPos
,_xCol
,_xIndexes
);
56 //------------------------------------------------------------------
57 OFILEOperandAttr::OFILEOperandAttr(sal_uInt16 _nPos
,
58 const Reference
< XPropertySet
>& _xColumn
,
59 const Reference
< XNameAccess
>& _xIndexes
)
60 : OOperandAttr(_nPos
,_xColumn
)
64 ::rtl::OUString sName
;
65 Reference
<XPropertySetInfo
> xColInfo
= _xColumn
->getPropertySetInfo();
66 Reference
<XPropertySet
> xIndex
;
68 Sequence
< ::rtl::OUString
> aSeq
= _xIndexes
->getElementNames();
69 const ::rtl::OUString
* pBegin
= aSeq
.getConstArray();
70 const ::rtl::OUString
* pEnd
= pBegin
+ aSeq
.getLength();
71 for(;pBegin
!= pEnd
;++pBegin
)
73 _xIndexes
->getByName(*pBegin
) >>= xIndex
;
76 Reference
<XColumnsSupplier
> xColsSup(xIndex
,UNO_QUERY
);
77 Reference
<XNameAccess
> xNameAccess
= xColsSup
->getColumns();
78 _xColumn
->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME
)) >>= sName
;
79 if(xNameAccess
->hasByName(sName
))
84 else if(xColInfo
->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME
)))
86 _xColumn
->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME
)) >>= sName
;
87 if(xNameAccess
->hasByName(sName
))
98 // -------------------------------------------------------------------------
99 sal_Bool
OFILEOperandAttr::isIndexed() const
101 return m_xIndex
.is();
103 //------------------------------------------------------------------
104 OEvaluateSet
* OFILEOperandAttr::preProcess(OBoolOperator
* pOp
, OOperand
* pRight
)
106 OEvaluateSet
* pEvaluateSet
= NULL
;
109 Reference
<XUnoTunnel
> xTunnel(m_xIndex
,UNO_QUERY
);
112 ODbaseIndex
* pIndex
= reinterpret_cast< ODbaseIndex
* >( xTunnel
->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
115 OIndexIterator
* pIter
= pIndex
->createIterator(pOp
,pRight
);
119 pEvaluateSet
= new OEvaluateSet();
120 ULONG nRec
= pIter
->First();
121 while (nRec
!= NODE_NOTFOUND
)
123 (*pEvaluateSet
)[nRec
] = nRec
;
124 nRec
= pIter
->Next();