Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / dbaccess / source / ui / inc / TableWindow.hxx
blob2ccf236d0c9819fc35face051f8b6254b640e4c5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
21 #include <com/sun/star/container/XNameAccess.hpp>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include "TableWindowTitle.hxx"
24 #include <rtl/ref.hxx>
25 #include "TableWindowData.hxx"
26 #include "TableWindowListBox.hxx"
27 #include <vector>
28 #include <vcl/window.hxx>
30 #include <comphelper/containermultiplexer.hxx>
31 #include <cppuhelper/basemutex.hxx>
32 #include <o3tl/typed_flags_set.hxx>
34 // Flags for the size adjustment of SbaJoinTabWins
35 enum class SizingFlags {
36 NONE = 0x0000,
37 Top = 0x0001,
38 Bottom = 0x0002,
39 Left = 0x0004,
40 Right = 0x0008,
42 namespace o3tl {
43 template<> struct typed_flags<SizingFlags> : is_typed_flags<SizingFlags, 0x0f> {};
47 namespace dbaui
49 class OJoinDesignView;
50 class OJoinTableView;
51 class OTableWindowAccess;
53 class OTableWindow : public ::cppu::BaseMutex
54 ,public ::comphelper::OContainerListener
55 ,public vcl::Window
57 friend class OTableWindowTitle;
58 friend class OTableWindowListBox;
59 protected:
60 // and the table itself (needed for me as I want to lock it as long as the window is alive)
61 VclPtr<OTableWindowTitle> m_xTitle;
62 VclPtr<OTableWindowListBox> m_xListBox;
64 private:
65 TTableWindowData::value_type
66 m_pData;
67 ::rtl::Reference< comphelper::OContainerListenerAdapter>
68 m_pContainerListener;
69 sal_Int32 m_nMoveCount; // how often the arrow keys was pressed
70 sal_Int32 m_nMoveIncrement; // how many pixel we should move
71 SizingFlags m_nSizingFlags;
73 // OContainerListener
74 virtual void _elementInserted( const css::container::ContainerEvent& _rEvent ) override;
75 virtual void _elementRemoved( const css::container::ContainerEvent& _rEvent ) override;
76 virtual void _elementReplaced( const css::container::ContainerEvent& _rEvent ) override;
78 protected:
79 virtual void Resize() override;
80 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
81 virtual void MouseMove( const MouseEvent& rEvt ) override;
82 virtual void MouseButtonDown( const MouseEvent& rEvt ) override;
83 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
85 // called at FIRST Init
86 void FillListBox();
87 // called at EACH Init
89 virtual void OnEntryDoubleClicked(weld::TreeIter& /*rEntry*/) { }
90 // called from the DoubleClickHdl of the ListBox
92 /** delete the user data with the equal type as created within createUserData
93 @param _pUserData
94 The user data store in the listbox entries. Created with a call to createUserData.
95 _pUserData may be <NULL/>. _pUserData will be set to <NULL/> after call.
97 virtual void deleteUserData(void*& _pUserData);
99 /** creates user information that will be append at the ListBoxentry
100 @param _xColumn
101 The corresponding column, can be <NULL/>.
102 @param _bPrimaryKey
103 <TRUE/> when the column belongs to the primary key
104 @return
105 the user data which will be append at the listbox entry, may be <NULL/>
107 virtual void* createUserData(const css::uno::Reference<
108 css::beans::XPropertySet>& _xColumn,
109 bool _bPrimaryKey);
111 /** updates image
113 void impl_updateImage();
115 OTableWindow( vcl::Window* pParent, TTableWindowData::value_type aTabWinData );
117 public:
118 virtual ~OTableWindow() override;
119 virtual void dispose() override;
121 // late Constructor, see also CreateListbox and FillListbox
122 virtual bool Init();
124 OJoinTableView* getTableView();
125 const OJoinTableView* getTableView() const;
126 OJoinDesignView* getDesignView();
127 void SetPosPixel( const Point& rNewPos ) override;
128 void SetSizePixel( const Size& rNewSize ) override;
129 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) override;
131 OUString getTitle() const;
132 void SetBoldTitle( bool bBold );
133 void setActive(bool _bActive = true);
135 void Remove();
137 OUString const & GetTableName() const { return m_pData->GetTableName(); }
138 OUString const & GetWinName() const { return m_pData->GetWinName(); }
139 OUString const & GetComposedName() const { return m_pData->GetComposedName(); }
140 const VclPtr<OTableWindowListBox>& GetListBox() const { return m_xListBox; }
141 const TTableWindowData::value_type& GetData() const { return m_pData; }
142 const VclPtr<OTableWindowTitle>& GetTitleCtrl() const { return m_xTitle; }
144 /** returns the name which should be used when displaying join or relations
145 @return
146 The composed name or the window name.
148 virtual OUString GetName() const = 0;
150 css::uno::Reference< css::container::XNameAccess > GetOriginalColumns() const { return m_pData->getColumns(); }
151 css::uno::Reference< css::beans::XPropertySet > GetTable() const { return m_pData->getTable(); }
153 /** set the sizing flag to the direction
154 @param _rPos
155 The EndPosition after resizing.
157 void setSizingFlag(const Point& _rPos);
159 /** returns the new sizing
161 tools::Rectangle getSizingRect(const Point& _rPos,const Size& _rOutputSize) const;
163 // window override
164 virtual void StateChanged( StateChangedType nStateChange ) override;
165 virtual void GetFocus() override;
166 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
167 virtual void Command(const CommandEvent& rEvt) override;
169 // Accessibility
170 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
172 // do I have connections to the outside?
173 bool ExistsAConn() const;
175 void EnumValidFields(std::vector< OUString>& arrstrFields);
177 /** clears the listbox inside. Must be called be the dtor is called.
179 void clearListBox();
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */