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 .
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"
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
{
43 template<> struct typed_flags
<SizingFlags
> : is_typed_flags
<SizingFlags
, 0x0f> {};
49 class OJoinDesignView
;
51 class OTableWindowAccess
;
53 class OTableWindow
: public ::cppu::BaseMutex
54 ,public ::comphelper::OContainerListener
57 friend class OTableWindowTitle
;
58 friend class OTableWindowListBox
;
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
;
65 TTableWindowData::value_type
67 ::rtl::Reference
< comphelper::OContainerListenerAdapter
>
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
;
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
;
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
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
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
101 The corresponding column, can be <NULL/>.
103 <TRUE/> when the column belongs to the primary key
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
,
113 void impl_updateImage();
115 OTableWindow( vcl::Window
* pParent
, TTableWindowData::value_type aTabWinData
);
118 virtual ~OTableWindow() override
;
119 virtual void dispose() override
;
121 // late Constructor, see also CreateListbox and FillListbox
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);
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
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
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;
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
;
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.
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */