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