xref: /AOO41X/main/dbaccess/source/ui/inc/TableWindowData.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOWDATA_HXX
28*cdf0e10cSrcweir #define DBAUI_TABLEWINDOWDATA_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #ifndef _SV_GEN_HXX
31*cdf0e10cSrcweir #include <tools/gen.hxx>
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
37*cdf0e10cSrcweir #include <unotools/eventlisteneradapter.hxx>
38*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
39*cdf0e10cSrcweir #include <vector>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace dbaui
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir     class OTableWindowData : public ::utl::OEventListenerAdapter
44*cdf0e10cSrcweir 	{
45*cdf0e10cSrcweir         mutable ::osl::Mutex	m_aMutex;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir         void listen();
48*cdf0e10cSrcweir 	protected:
49*cdf0e10cSrcweir         // the columns of the table
50*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xTable; // can either be a table or a query
51*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>    m_xKeys;
52*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xColumns;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 		::rtl::OUString	m_aTableName;
55*cdf0e10cSrcweir 		::rtl::OUString	m_aWinName;
56*cdf0e10cSrcweir 		::rtl::OUString	m_sComposedName;
57*cdf0e10cSrcweir 		Point			m_aPosition;
58*cdf0e10cSrcweir 		Size			m_aSize;
59*cdf0e10cSrcweir 		sal_Bool		m_bShowAll;
60*cdf0e10cSrcweir         bool            m_bIsQuery;
61*cdf0e10cSrcweir         bool            m_bIsValid;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	public:
64*cdf0e10cSrcweir 		explicit OTableWindowData(  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
65*cdf0e10cSrcweir                                    ,const ::rtl::OUString& _rComposedName
66*cdf0e10cSrcweir                                    ,const ::rtl::OUString& strTableName
67*cdf0e10cSrcweir                                    ,const ::rtl::OUString& rWinName = ::rtl::OUString() );
68*cdf0e10cSrcweir 		virtual ~OTableWindowData();
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir         /** late constructor
71*cdf0e10cSrcweir         *
72*cdf0e10cSrcweir         * \param _xConnection
73*cdf0e10cSrcweir         * \param _bAllowQueries when true, queries are allowed
74*cdf0e10cSrcweir         * \return false if the table was unaccessible otherwise true
75*cdf0e10cSrcweir         */
76*cdf0e10cSrcweir         bool init(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection  >& _xConnection
77*cdf0e10cSrcweir                  ,bool _bAllowQueries);
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 		inline ::rtl::OUString GetComposedName()	const { return m_sComposedName; }
80*cdf0e10cSrcweir 		inline ::rtl::OUString GetTableName()		const { return m_aTableName; }
81*cdf0e10cSrcweir 		inline ::rtl::OUString GetWinName()		    const { return m_aWinName; }
82*cdf0e10cSrcweir 		inline Point GetPosition()					const { return m_aPosition; }
83*cdf0e10cSrcweir 		inline Size GetSize()						const { return m_aSize; }
84*cdf0e10cSrcweir 		inline sal_Bool IsShowAll()					    const { return m_bShowAll; }
85*cdf0e10cSrcweir         inline bool isQuery()                       const { return m_bIsQuery; }
86*cdf0e10cSrcweir         inline bool isValid()                       const { return m_bIsValid; } // it is either a table or query but it is known
87*cdf0e10cSrcweir 		sal_Bool HasPosition()	const;
88*cdf0e10cSrcweir 		sal_Bool HasSize()		const;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 		inline void SetWinName( const ::rtl::OUString& rWinName )		{ m_aWinName = rWinName; }
91*cdf0e10cSrcweir 		inline void SetPosition( const Point& rPos )					{ m_aPosition=rPos; }
92*cdf0e10cSrcweir 		inline void SetSize( const Size& rSize )						{ m_aSize = rSize; }
93*cdf0e10cSrcweir 		inline void ShowAll( sal_Bool bAll )								{ m_bShowAll = bAll; }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getTable() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xTable; }
96*cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> getKeys() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xKeys; }
97*cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getColumns() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xColumns; }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir         // OEventListenerAdapter
100*cdf0e10cSrcweir 		virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
101*cdf0e10cSrcweir 	};
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     typedef ::std::vector< ::boost::shared_ptr<OTableWindowData> >		TTableWindowData;
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir #endif // DBAUI_TABLEWINDOWDATA_HXX
106*cdf0e10cSrcweir 
107