1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOWDATA_HXX
24cdf0e10cSrcweir #define DBAUI_TABLEWINDOWDATA_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _SV_GEN_HXX
27cdf0e10cSrcweir #include <tools/gen.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
31cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
33cdf0e10cSrcweir #include <unotools/eventlisteneradapter.hxx>
34cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
35cdf0e10cSrcweir #include <vector>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace dbaui
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     class OTableWindowData : public ::utl::OEventListenerAdapter
40cdf0e10cSrcweir 	{
41cdf0e10cSrcweir         mutable ::osl::Mutex	m_aMutex;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir         void listen();
44cdf0e10cSrcweir 	protected:
45cdf0e10cSrcweir         // the columns of the table
46cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xTable; // can either be a table or a query
47cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>    m_xKeys;
48cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xColumns;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 		::rtl::OUString	m_aTableName;
51cdf0e10cSrcweir 		::rtl::OUString	m_aWinName;
52cdf0e10cSrcweir 		::rtl::OUString	m_sComposedName;
53cdf0e10cSrcweir 		Point			m_aPosition;
54cdf0e10cSrcweir 		Size			m_aSize;
55cdf0e10cSrcweir 		sal_Bool		m_bShowAll;
56cdf0e10cSrcweir         bool            m_bIsQuery;
57cdf0e10cSrcweir         bool            m_bIsValid;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	public:
60cdf0e10cSrcweir 		explicit OTableWindowData(  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
61cdf0e10cSrcweir                                    ,const ::rtl::OUString& _rComposedName
62cdf0e10cSrcweir                                    ,const ::rtl::OUString& strTableName
63cdf0e10cSrcweir                                    ,const ::rtl::OUString& rWinName = ::rtl::OUString() );
64cdf0e10cSrcweir 		virtual ~OTableWindowData();
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         /** late constructor
67cdf0e10cSrcweir         *
68cdf0e10cSrcweir         * \param _xConnection
69cdf0e10cSrcweir         * \param _bAllowQueries when true, queries are allowed
70cdf0e10cSrcweir         * \return false if the table was unaccessible otherwise true
71cdf0e10cSrcweir         */
72cdf0e10cSrcweir         bool init(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection  >& _xConnection
73cdf0e10cSrcweir                  ,bool _bAllowQueries);
74cdf0e10cSrcweir 
GetComposedName() const75cdf0e10cSrcweir 		inline ::rtl::OUString GetComposedName()	const { return m_sComposedName; }
GetTableName() const76cdf0e10cSrcweir 		inline ::rtl::OUString GetTableName()		const { return m_aTableName; }
GetWinName() const77cdf0e10cSrcweir 		inline ::rtl::OUString GetWinName()		    const { return m_aWinName; }
GetPosition() const78cdf0e10cSrcweir 		inline Point GetPosition()					const { return m_aPosition; }
GetSize() const79cdf0e10cSrcweir 		inline Size GetSize()						const { return m_aSize; }
IsShowAll() const80cdf0e10cSrcweir 		inline sal_Bool IsShowAll()					    const { return m_bShowAll; }
isQuery() const81cdf0e10cSrcweir         inline bool isQuery()                       const { return m_bIsQuery; }
isValid() const82cdf0e10cSrcweir         inline bool isValid()                       const { return m_bIsValid; } // it is either a table or query but it is known
83cdf0e10cSrcweir 		sal_Bool HasPosition()	const;
84cdf0e10cSrcweir 		sal_Bool HasSize()		const;
85cdf0e10cSrcweir 
SetWinName(const::rtl::OUString & rWinName)86cdf0e10cSrcweir 		inline void SetWinName( const ::rtl::OUString& rWinName )		{ m_aWinName = rWinName; }
SetPosition(const Point & rPos)87cdf0e10cSrcweir 		inline void SetPosition( const Point& rPos )					{ m_aPosition=rPos; }
SetSize(const Size & rSize)88cdf0e10cSrcweir 		inline void SetSize( const Size& rSize )						{ m_aSize = rSize; }
ShowAll(sal_Bool bAll)89cdf0e10cSrcweir 		inline void ShowAll( sal_Bool bAll )								{ m_bShowAll = bAll; }
90cdf0e10cSrcweir 
getTable() const91cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getTable() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xTable; }
getKeys() const92cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> getKeys() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xKeys; }
getColumns() const93cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getColumns() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xColumns; }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir         // OEventListenerAdapter
96cdf0e10cSrcweir 		virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
97cdf0e10cSrcweir 	};
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     typedef ::std::vector< ::boost::shared_ptr<OTableWindowData> >		TTableWindowData;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir #endif // DBAUI_TABLEWINDOWDATA_HXX
102cdf0e10cSrcweir 
103