1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEWINDOW_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEWINDOW_HXX
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 "TableWindowListBox.hxx"
30 #include <vcl/window.hxx>
32 #include <comphelper/containermultiplexer.hxx>
33 #include "cppuhelper/basemutex.hxx"
35 class SvTreeListEntry
;
38 // Flags for the size adjustment of 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;
45 class OJoinDesignView
;
47 class OTableWindowAccess
;
49 class OTableWindow
: public ::cppu::BaseMutex
50 ,public ::comphelper::OContainerListener
53 friend class OTableWindowTitle
;
54 friend class OTableWindowListBox
;
56 // and the table itself (needed for me as I want to lock it as long as the window is alive)
57 VclPtr
<FixedImage
> m_aTypeImage
;
58 VclPtr
<OTableWindowTitle
> m_xTitle
;
59 VclPtr
<OTableWindowListBox
> m_xListBox
;
60 OTableWindowAccess
* m_pAccessible
;
63 TTableWindowData::value_type
65 ::rtl::Reference
< comphelper::OContainerListenerAdapter
>
67 sal_Int32 m_nMoveCount
; // how often the arrow keys was pressed
68 sal_Int32 m_nMoveIncrement
; // how many pixel we should move
69 sal_uInt16 m_nSizingFlags
;
73 virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent
& _rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
74 virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent
& _rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
75 virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent
& _rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
78 virtual void Resize() SAL_OVERRIDE
;
79 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
80 virtual void MouseMove( const MouseEvent
& rEvt
) SAL_OVERRIDE
;
81 virtual void MouseButtonDown( const MouseEvent
& rEvt
) SAL_OVERRIDE
;
82 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
84 VclPtr
<OTableWindowListBox
> CreateListBox();
85 // called at FIRST Init
87 // called at EACH Init
89 virtual void OnEntryDoubleClicked(SvTreeListEntry
* /*pEntry*/) { }
90 // called from the DoubleClickHdl of the ListBox
92 /** HandleKeyInput tries to handle the KeyEvent. Movement or deletion
96 <TRUE/> when the table could handle the keyevent.
98 bool HandleKeyInput( const KeyEvent
& rEvt
);
100 /** delete the user data with the equal type as created within createUserData
102 The user data store in the listbox entries. Created with a call to createUserData.
103 _pUserData may be <NULL/>. _pUserData will be set to <NULL/> after call.
105 virtual void deleteUserData(void*& _pUserData
);
107 /** creates user information that will be append at the ListBoxentry
109 The corresponding column, can be <NULL/>.
111 <TRUE/> when the column belongs to the primary key
113 the user data which will be append at the listbox entry, may be <NULL/>
115 virtual void* createUserData(const ::com::sun::star::uno::Reference
<
116 ::com::sun::star::beans::XPropertySet
>& _xColumn
,
119 /** updates m_aTypeImage
121 void impl_updateImage();
123 OTableWindow( vcl::Window
* pParent
, const TTableWindowData::value_type
& pTabWinData
);
126 virtual ~OTableWindow();
127 virtual void dispose() SAL_OVERRIDE
;
129 // late Constructor, see also CreateListbox and FillListbox
132 OJoinTableView
* getTableView();
133 const OJoinTableView
* getTableView() const;
134 OJoinDesignView
* getDesignView();
135 void SetPosPixel( const Point
& rNewPos
) SAL_OVERRIDE
;
136 void SetSizePixel( const Size
& rNewSize
) SAL_OVERRIDE
;
137 void SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
) SAL_OVERRIDE
;
139 OUString
getTitle() const;
140 void SetBoldTitle( bool bBold
);
141 void setActive(bool _bActive
= true);
144 bool IsActiveWindow(){ return m_bActive
; }
146 OUString
GetTableName() const { return m_pData
->GetTableName(); }
147 OUString
GetWinName() const { return m_pData
->GetWinName(); }
148 OUString
GetComposedName() const { return m_pData
->GetComposedName(); }
149 VclPtr
<OTableWindowListBox
> GetListBox() const { return m_xListBox
; }
150 TTableWindowData::value_type
GetData() const { return m_pData
; }
151 VclPtr
<OTableWindowTitle
> GetTitleCtrl() { return m_xTitle
; }
153 /** returns the name which should be used when displaying join or relations
155 The composed name or the window name.
157 virtual OUString
GetName() const = 0;
159 inline ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> GetOriginalColumns() const { return m_pData
->getColumns(); }
160 inline ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> GetTable() const { return m_pData
->getTable(); }
162 sal_uInt16
GetSizingFlags() const { return m_nSizingFlags
; }
163 /** set the sizing flag to the direction
165 The EndPosition after resizing.
167 void setSizingFlag(const Point
& _rPos
);
168 /** set the rsizing flag to NONE.
170 void resetSizingFlag() { m_nSizingFlags
= SIZING_NONE
; }
172 /** returns the new sizing
174 Rectangle
getSizingRect(const Point
& _rPos
,const Size
& _rOutputSize
) const;
177 virtual void StateChanged( StateChangedType nStateChange
) SAL_OVERRIDE
;
178 virtual void GetFocus() SAL_OVERRIDE
;
179 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
180 virtual void Command(const CommandEvent
& rEvt
) SAL_OVERRIDE
;
183 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible() SAL_OVERRIDE
;
185 // do I have connections to the outside?
186 bool ExistsAConn() const;
188 void EnumValidFields(::std::vector
< OUString
>& arrstrFields
);
190 /** clears the listbox inside. Must be called be the dtor is called.
195 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEWINDOW_HXX
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */