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: VView.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 "connectivity/sdbcx/VView.hxx"
34 #include <com/sun/star/lang/DisposedException.hpp>
35 #include <comphelper/sequence.hxx>
36 #include "connectivity/dbtools.hxx"
37 #include "TConnection.hxx"
39 // -------------------------------------------------------------------------
40 using namespace connectivity
;
41 using namespace connectivity::sdbcx
;
42 using namespace ::com::sun::star::beans
;
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::sdbcx
;
45 using namespace ::com::sun::star::container
;
46 using namespace ::com::sun::star::lang
;
48 IMPLEMENT_SERVICE_INFO(OView
,"com.sun.star.sdbcx.VView","com.sun.star.sdbcx.View");
49 // -------------------------------------------------------------------------
50 OView::OView(sal_Bool _bCase
,
51 const ::rtl::OUString
& _Name
,
52 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
>& _xMetaData
,
53 sal_Int32 _CheckOption
,
54 const ::rtl::OUString
& _Command
,
55 const ::rtl::OUString
& _SchemaName
,
56 const ::rtl::OUString
& _CatalogName
) : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper
,_bCase
)
57 ,m_CatalogName(_CatalogName
)
58 ,m_SchemaName(_SchemaName
)
60 ,m_CheckOption(_CheckOption
)
61 ,m_xMetaData(_xMetaData
)
67 // -------------------------------------------------------------------------
68 OView::OView(sal_Bool _bCase
,const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
>& _xMetaData
)
69 : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper
,_bCase
,sal_True
)
70 ,m_xMetaData(_xMetaData
)
74 // -------------------------------------------------------------------------
78 // -------------------------------------------------------------------------
79 void OView::construct()
81 ODescriptor::construct();
83 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
85 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME
), PROPERTY_ID_CATALOGNAME
,nAttrib
,&m_CatalogName
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
86 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME
), PROPERTY_ID_SCHEMANAME
, nAttrib
,&m_SchemaName
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
87 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND
), PROPERTY_ID_COMMAND
, nAttrib
,&m_Command
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
88 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CHECKOPTION
), PROPERTY_ID_CHECKOPTION
,nAttrib
,&m_CheckOption
, ::getCppuType(reinterpret_cast< sal_Int32
*>(NULL
)));
90 // -------------------------------------------------------------------------
91 void OView::disposing(void)
93 OPropertySetHelper::disposing();
95 ::osl::MutexGuard
aGuard(m_aMutex
);
97 // -------------------------------------------------------------------------
98 Sequence
< Type
> SAL_CALL
OView::getTypes( ) throw(RuntimeException
)
100 return ::comphelper::concatSequences(ODescriptor::getTypes(),OView_BASE::getTypes());
102 // -------------------------------------------------------------------------
103 Any SAL_CALL
OView::queryInterface( const Type
& rType
) throw(RuntimeException
)
105 Any aRet
= OView_BASE::queryInterface( rType
);
106 return aRet
.hasValue() ? aRet
: ODescriptor::queryInterface( rType
);
108 // -------------------------------------------------------------------------
109 ::cppu::IPropertyArrayHelper
* OView::createArrayHelper( sal_Int32
/*_nId*/ ) const
111 return doCreateArrayHelper();
113 // -------------------------------------------------------------------------
114 ::cppu::IPropertyArrayHelper
& OView::getInfoHelper()
116 return *const_cast<OView
*>(this)->getArrayHelper(isNew() ? 1 : 0);
118 // -----------------------------------------------------------------------------
119 ::rtl::OUString SAL_CALL
OView::getName() throw(::com::sun::star::uno::RuntimeException
)
121 ::rtl::OUString sComposedName
;
123 sComposedName
= ::dbtools::composeTableName( m_xMetaData
, m_CatalogName
, m_SchemaName
, m_Name
, sal_False
, ::dbtools::eInDataManipulation
);
127 getFastPropertyValue(aValue
,PROPERTY_ID_NAME
);
128 aValue
>>= sComposedName
;
130 return sComposedName
;
132 // -----------------------------------------------------------------------------
133 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OView::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
)
135 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
137 // -----------------------------------------------------------------------------
138 void SAL_CALL
OView::setName( const ::rtl::OUString
& ) throw(::com::sun::star::uno::RuntimeException
)
141 // -----------------------------------------------------------------------------
142 void SAL_CALL
OView::acquire() throw()
144 OView_BASE::acquire();
146 // -----------------------------------------------------------------------------
147 void SAL_CALL
OView::release() throw()
149 OView_BASE::release();
151 // -----------------------------------------------------------------------------