Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef DBAUI_TABLEWINDOW_HXX
20 : #define DBAUI_TABLEWINDOW_HXX
21 :
22 : #include <com/sun/star/container/XNameAccess.hpp>
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include "TableWindowTitle.hxx"
25 : #include <tools/rtti.hxx>
26 : #include <rtl/ref.hxx>
27 : #include "TableWindowData.hxx"
28 : #include <vector>
29 : #include <vcl/window.hxx>
30 :
31 : #include <comphelper/containermultiplexer.hxx>
32 : #include "cppuhelper/basemutex.hxx"
33 :
34 : class SvTreeListEntry;
35 : namespace dbaui
36 : {
37 : //////////////////////////////////////////////////////////////////////////
38 : // Flags fuer die Groessenanpassung der SbaJoinTabWins
39 : const sal_uInt16 SIZING_NONE = 0x0000;
40 : const sal_uInt16 SIZING_TOP = 0x0001;
41 : const sal_uInt16 SIZING_BOTTOM = 0x0002;
42 : const sal_uInt16 SIZING_LEFT = 0x0004;
43 : const sal_uInt16 SIZING_RIGHT = 0x0008;
44 :
45 : class OTableWindowListBox;
46 : class OJoinDesignView;
47 : class OJoinTableView;
48 : class OTableWindowAccess;
49 :
50 : class OTableWindow : public ::cppu::BaseMutex
51 : ,public ::comphelper::OContainerListener
52 : ,public Window
53 : {
54 : friend class OTableWindowTitle;
55 : friend class OTableWindowListBox;
56 : protected:
57 : // and the table itself (needed for me as I want to lock it as long as the window is alive)
58 : FixedImage m_aTypeImage;
59 : OTableWindowTitle m_aTitle;
60 : OTableWindowListBox* m_pListBox;
61 : OTableWindowAccess* m_pAccessible;
62 :
63 : private:
64 : TTableWindowData::value_type
65 : m_pData;
66 : ::rtl::Reference< comphelper::OContainerListenerAdapter>
67 : m_pContainerListener;
68 : sal_Int32 m_nMoveCount; // how often the arrow keys was pressed
69 : sal_Int32 m_nMoveIncrement; // how many pixel we should move
70 : sal_uInt16 m_nSizingFlags;
71 : sal_Bool m_bActive;
72 :
73 : void Draw3DBorder( const Rectangle& rRect );
74 : // OContainerListener
75 : virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
76 : virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
77 : virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
78 :
79 : protected:
80 : virtual void Resize();
81 : virtual void Paint( const Rectangle& rRect );
82 : virtual void MouseMove( const MouseEvent& rEvt );
83 : virtual void MouseButtonDown( const MouseEvent& rEvt );
84 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
85 :
86 : virtual OTableWindowListBox* CreateListBox();
87 : // called at FIRST Init
88 : sal_Bool FillListBox();
89 : // called at EACH Init
90 :
91 0 : virtual void OnEntryDoubleClicked(SvTreeListEntry* /*pEntry*/) { }
92 : // called from the DoubleClickHdl of the ListBox
93 :
94 : /** HandleKeyInput tries to handle the KeyEvent. Movement or deletion
95 : @param rEvt
96 : The KEyEvent
97 : @return
98 : <TRUE/> when the table could handle the keyevent.
99 : */
100 : sal_Bool HandleKeyInput( const KeyEvent& rEvt );
101 :
102 : /** delete the user data with the equal type as created within createUserData
103 : @param _pUserData
104 : The user data store in the listbox entries. Created with a call to createUserData.
105 : _pUserData may be <NULL/>. _pUserData will be set to <NULL/> after call.
106 : */
107 : virtual void deleteUserData(void*& _pUserData);
108 :
109 : /** creates user information that will be append at the ListBoxentry
110 : @param _xColumn
111 : The corresponding column, can be <NULL/>.
112 : @param _bPrimaryKey
113 : <TRUE/> when the column belongs to the primary key
114 : @return
115 : the user data which will be append at the listbox entry, may be <NULL/>
116 : */
117 : virtual void* createUserData(const ::com::sun::star::uno::Reference<
118 : ::com::sun::star::beans::XPropertySet>& _xColumn,
119 : bool _bPrimaryKey);
120 :
121 : /** updates m_aTypeImage
122 : */
123 : void impl_updateImage();
124 :
125 : OTableWindow( Window* pParent, const TTableWindowData::value_type& pTabWinData );
126 :
127 : public:
128 : virtual ~OTableWindow();
129 :
130 : // late Constructor, see also CreateListbox and FillListbox
131 : virtual sal_Bool Init();
132 :
133 : OJoinTableView* getTableView();
134 : const OJoinTableView* getTableView() const;
135 : OJoinDesignView* getDesignView();
136 : void SetPosPixel( const Point& rNewPos );
137 : void SetSizePixel( const Size& rNewSize );
138 : void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize );
139 :
140 : String getTitle() const;
141 : void SetBoldTitle( sal_Bool bBold );
142 : void setActive(sal_Bool _bActive = sal_True);
143 :
144 : void Remove();
145 : sal_Bool IsActiveWindow(){ return m_bActive; }
146 :
147 0 : ::rtl::OUString GetTableName() const { return m_pData->GetTableName(); }
148 0 : ::rtl::OUString GetWinName() const { return m_pData->GetWinName(); }
149 0 : ::rtl::OUString GetComposedName() const { return m_pData->GetComposedName(); }
150 0 : OTableWindowListBox* GetListBox() const { return m_pListBox; }
151 0 : TTableWindowData::value_type GetData() const { return m_pData; }
152 0 : OTableWindowTitle* GetTitleCtrl() { return &m_aTitle; }
153 :
154 : /** returns the name which should be used when displaying join or relations
155 : @return
156 : The composed name or the window name.
157 : */
158 : virtual ::rtl::OUString GetName() const = 0;
159 :
160 0 : inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > GetOriginalColumns() const { return m_pData->getColumns(); }
161 0 : inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetTable() const { return m_pData->getTable(); }
162 :
163 0 : sal_uInt16 GetSizingFlags() const { return m_nSizingFlags; }
164 : /** set the sizing flag to the direction
165 : @param _rPos
166 : The EndPosition after resizing.
167 : */
168 : void setSizingFlag(const Point& _rPos);
169 : /** set the rsizing flag to NONE.
170 : */
171 0 : void resetSizingFlag() { m_nSizingFlags = SIZING_NONE; }
172 :
173 : /** returns the new sizing
174 : */
175 : Rectangle getSizingRect(const Point& _rPos,const Size& _rOutputSize) const;
176 :
177 : // window override
178 : virtual void StateChanged( StateChangedType nStateChange );
179 : virtual void GetFocus();
180 : virtual long PreNotify( NotifyEvent& rNEvt );
181 : virtual void Command(const CommandEvent& rEvt);
182 :
183 : // Accessibility
184 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
185 :
186 : // do I have connections to the outside?
187 : sal_Bool ExistsAConn() const;
188 :
189 : void EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields);
190 :
191 : /** clears the listbox inside. Must be called be the dtor is called.
192 : */
193 : void clearListBox();
194 : };
195 : }
196 : #endif //DBAUI_TABLEWINDOW_HXX
197 :
198 :
199 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|