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_TABLEWINDOW_HXX
24cdf0e10cSrcweir #define DBAUI_TABLEWINDOW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
27cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
28cdf0e10cSrcweir #include "TableWindowTitle.hxx"
29cdf0e10cSrcweir #include <tools/rtti.hxx>
30cdf0e10cSrcweir #include <rtl/ref.hxx>
31cdf0e10cSrcweir #include "TableWindowData.hxx"
32cdf0e10cSrcweir #include <vector>
33cdf0e10cSrcweir #include <vcl/window.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <comphelper/containermultiplexer.hxx>
36cdf0e10cSrcweir #include "cppuhelper/basemutex.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class SvLBoxEntry;
39cdf0e10cSrcweir namespace dbaui
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////////
42cdf0e10cSrcweir 	// Flags fuer die Groessenanpassung der SbaJoinTabWins
43cdf0e10cSrcweir 	const sal_uInt16 SIZING_NONE	= 0x0000;
44cdf0e10cSrcweir 	const sal_uInt16 SIZING_TOP		= 0x0001;
45cdf0e10cSrcweir 	const sal_uInt16 SIZING_BOTTOM	= 0x0002;
46cdf0e10cSrcweir 	const sal_uInt16 SIZING_LEFT	= 0x0004;
47cdf0e10cSrcweir 	const sal_uInt16 SIZING_RIGHT	= 0x0008;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	class OTableWindowListBox;
50cdf0e10cSrcweir 	class OJoinDesignView;
51cdf0e10cSrcweir 	class OJoinTableView;
52cdf0e10cSrcweir 	class OTableWindowAccess;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	class OTableWindow : public ::cppu::BaseMutex
55cdf0e10cSrcweir                         ,public ::comphelper::OContainerListener
56cdf0e10cSrcweir                         ,public Window
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		friend class OTableWindowTitle;
59cdf0e10cSrcweir 		friend class OTableWindowListBox;
60cdf0e10cSrcweir     protected:
61cdf0e10cSrcweir 		// und die Tabelle selber (brauche ich, da ich sie locken will, solange das Fenster lebt)
62cdf0e10cSrcweir         FixedImage              m_aTypeImage;
63cdf0e10cSrcweir 		OTableWindowTitle		m_aTitle;
64cdf0e10cSrcweir 		OTableWindowListBox*	m_pListBox;
65cdf0e10cSrcweir 		OTableWindowAccess*		m_pAccessible;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	private:
68cdf0e10cSrcweir         TTableWindowData::value_type
69cdf0e10cSrcweir                                 m_pData;
70cdf0e10cSrcweir         ::rtl::Reference< comphelper::OContainerListenerAdapter>
71cdf0e10cSrcweir                                 m_pContainerListener;
72cdf0e10cSrcweir 		sal_Int32				m_nMoveCount;			// how often the arrow keys was pressed
73cdf0e10cSrcweir 		sal_Int32				m_nMoveIncrement;		// how many pixel we should move
74cdf0e10cSrcweir 		sal_uInt16					m_nSizingFlags;
75cdf0e10cSrcweir 		sal_Bool					m_bActive;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		void Draw3DBorder( const Rectangle& rRect );
78cdf0e10cSrcweir         // OContainerListener
79cdf0e10cSrcweir         virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir 	    virtual void _elementRemoved( const  ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir 	    virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	protected:
84cdf0e10cSrcweir 		virtual void	Resize();
85cdf0e10cSrcweir 		virtual void	Paint( const Rectangle& rRect );
86cdf0e10cSrcweir 		virtual void	MouseMove( const MouseEvent& rEvt );
87cdf0e10cSrcweir 		virtual void	MouseButtonDown( const MouseEvent& rEvt );
88cdf0e10cSrcweir 		virtual void	DataChanged( const DataChangedEvent& rDCEvt );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 		virtual OTableWindowListBox*	CreateListBox();
91cdf0e10cSrcweir 			// wird im ERSTEN Init aufgerufen
92cdf0e10cSrcweir 		sal_Bool FillListBox();
93cdf0e10cSrcweir 			// wird in JEDEM Init aufgerufen
94cdf0e10cSrcweir 
OnEntryDoubleClicked(SvLBoxEntry *)95cdf0e10cSrcweir 		virtual void OnEntryDoubleClicked(SvLBoxEntry* /*pEntry*/) { }
96cdf0e10cSrcweir 			// wird aus dem DoubleClickHdl der ListBox heraus aufgerufen
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		/** HandleKeyInput triues to handle the KeyEvent. Movement or deletion
99cdf0e10cSrcweir 			@param	rEvt
100cdf0e10cSrcweir 				The KEyEvent
101cdf0e10cSrcweir 			@return
102cdf0e10cSrcweir 				<TRUE/> when the table could handle the keyevent.
103cdf0e10cSrcweir 		*/
104cdf0e10cSrcweir 		sal_Bool			HandleKeyInput( const KeyEvent& rEvt );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		/** delete the user data with the equal type as created within createUserData
107cdf0e10cSrcweir 			@param	_pUserData
108cdf0e10cSrcweir 				The user data store in the listbox entries. Created with a call to createUserData.
109cdf0e10cSrcweir 				_pUserData may be <NULL/>. _pUserData will be set to <NULL/> after call.
110cdf0e10cSrcweir 		*/
111cdf0e10cSrcweir 		virtual void deleteUserData(void*& _pUserData);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		/** creates user information that will be append at the ListBoxentry
114cdf0e10cSrcweir 			@param	_xColumn
115cdf0e10cSrcweir 				The corresponding column, can be <NULL/>.
116cdf0e10cSrcweir 			@param	_bPrimaryKey
117cdf0e10cSrcweir 				<TRUE/> when the column belongs to the primary key
118cdf0e10cSrcweir 			@return
119cdf0e10cSrcweir 				the user data which will be append at the listbox entry, may be <NULL/>
120cdf0e10cSrcweir 		*/
121cdf0e10cSrcweir 		virtual void* createUserData(const ::com::sun::star::uno::Reference<
122cdf0e10cSrcweir 									::com::sun::star::beans::XPropertySet>& _xColumn,
123cdf0e10cSrcweir 									bool _bPrimaryKey);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         /** updates m_aTypeImage
126cdf0e10cSrcweir         */
127cdf0e10cSrcweir         void    impl_updateImage();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		OTableWindow( Window* pParent, const TTableWindowData::value_type& pTabWinData );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	public:
132cdf0e10cSrcweir 		virtual ~OTableWindow();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 		// spaeter Constructor, siehe auch CreateListbox und FillListbox
135cdf0e10cSrcweir 		virtual sal_Bool Init();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 		OJoinTableView*				getTableView();
138cdf0e10cSrcweir 		const OJoinTableView*		getTableView() const;
139cdf0e10cSrcweir 		OJoinDesignView*			getDesignView();
140cdf0e10cSrcweir 		void						SetPosPixel( const Point& rNewPos );
141cdf0e10cSrcweir 		void						SetSizePixel( const Size& rNewSize );
142cdf0e10cSrcweir 		void						SetPosSizePixel( const Point& rNewPos, const Size& rNewSize );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		String						getTitle() const;
145cdf0e10cSrcweir 		void						SetBoldTitle( sal_Bool bBold );
146cdf0e10cSrcweir 		void						setActive(sal_Bool _bActive = sal_True);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		void						Remove();
IsActiveWindow()149cdf0e10cSrcweir 		sal_Bool						IsActiveWindow(){ return m_bActive; }
150cdf0e10cSrcweir 
GetTableName() const151cdf0e10cSrcweir 		::rtl::OUString				GetTableName() const { return m_pData->GetTableName(); }
GetWinName() const152cdf0e10cSrcweir 		::rtl::OUString				GetWinName() const { return m_pData->GetWinName(); }
GetComposedName() const153cdf0e10cSrcweir 		::rtl::OUString				GetComposedName() const { return m_pData->GetComposedName(); }
GetListBox() const154cdf0e10cSrcweir 		OTableWindowListBox*		GetListBox() const { return m_pListBox; }
GetData() const155cdf0e10cSrcweir 		TTableWindowData::value_type GetData() const { return m_pData; }
GetTitleCtrl()156cdf0e10cSrcweir 		OTableWindowTitle*			GetTitleCtrl() { return &m_aTitle; }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 		/** returns the name which should be used when displaying join or relations
159cdf0e10cSrcweir 			@return
160cdf0e10cSrcweir 				The composed name or the window name.
161cdf0e10cSrcweir 		*/
162cdf0e10cSrcweir 		virtual ::rtl::OUString		GetName() const = 0;
163cdf0e10cSrcweir 
GetOriginalColumns() const164cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > GetOriginalColumns() const { return m_pData->getColumns(); }
GetTable() const165cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >    GetTable() const { return m_pData->getTable(); }
166cdf0e10cSrcweir 
GetSizingFlags() const167cdf0e10cSrcweir 		sal_uInt16						GetSizingFlags() const { return m_nSizingFlags; }
168cdf0e10cSrcweir 		/** set the sizing flag to the direction
169cdf0e10cSrcweir 			@param	_rPos
170cdf0e10cSrcweir 				The EndPosition after resizing.
171cdf0e10cSrcweir 		*/
172cdf0e10cSrcweir 		void						setSizingFlag(const Point& _rPos);
173cdf0e10cSrcweir 		/** set the rsizing flag to NONE.
174cdf0e10cSrcweir 		*/
resetSizingFlag()175cdf0e10cSrcweir 		void						resetSizingFlag() { m_nSizingFlags = SIZING_NONE; }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 		/** returns the new sizing
178cdf0e10cSrcweir 		*/
179cdf0e10cSrcweir 		Rectangle getSizingRect(const Point& _rPos,const Size& _rOutputSize) const;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 		// window override
182cdf0e10cSrcweir 		virtual void				StateChanged( StateChangedType nStateChange );
183cdf0e10cSrcweir 		virtual void				GetFocus();
184cdf0e10cSrcweir 		virtual long				PreNotify( NotifyEvent& rNEvt );
185cdf0e10cSrcweir 		virtual void				Command(const CommandEvent& rEvt);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 		// Accessibility
188cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 		// habe ich Connections nach aussen ?
191cdf0e10cSrcweir 		sal_Bool ExistsAConn() const;
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 		void EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields);
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		/** clears the listbox inside. Must be called be the dtor is called.
196cdf0e10cSrcweir 		*/
197cdf0e10cSrcweir 		void clearListBox();
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     protected:
200cdf0e10cSrcweir         using Window::SetPosSizePixel;
201cdf0e10cSrcweir 	};
202cdf0e10cSrcweir }
203cdf0e10cSrcweir #endif //DBAUI_TABLEWINDOW_HXX
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 
206