LibreOffice Module dbaccess (master) 1
TableDesignView.cxx
Go to the documentation of this file.
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
20#include <TableDesignView.hxx>
21#include <TableController.hxx>
22#include <helpids.h>
23#include <FieldDescriptions.hxx>
24#include "TEditControl.hxx"
25#include "TableFieldDescWin.hxx"
26#include <TableRow.hxx>
30#include <memory>
31
32using namespace ::dbaui;
33using namespace ::com::sun::star::uno;
35using namespace ::com::sun::star::lang;
36using namespace ::com::sun::star::beans;
37
38OTableBorderWindow::OTableBorderWindow(OTableDesignView* pParent)
39 : InterimItemWindow(pParent, "dbaccess/ui/tableborderwindow.ui", "TableBorderWindow", false)
40 , m_xHorzSplitter(m_xBuilder->weld_paned("splitter"))
41 , m_xEditorParent(m_xBuilder->weld_container("editor"))
42 , m_xEditorParentWin(m_xEditorParent->CreateChildFrame())
43 , m_xEditorCtrl(VclPtr<OTableEditorCtrl>::Create(VCLUnoHelper::GetWindow(m_xEditorParentWin), pParent))
44 , m_xFieldDescParent(m_xBuilder->weld_container("fielddesc"))
45 , m_xFieldDescWin(new OTableFieldDescWin(m_xFieldDescParent.get(), pParent))
46{
48
50
51 // set depending windows and controls
52 m_xEditorCtrl->SetDescrWin(m_xFieldDescWin.get());
53}
54
56{
58}
59
61{
62 // destroy children
63 m_xEditorCtrl.disposeAndClear();
64 m_xEditorParentWin->dispose();
65 m_xEditorParentWin.clear();
66 m_xEditorParent.reset();
67 m_xFieldDescWin.reset();
68 m_xFieldDescParent.reset();
69 m_xHorzSplitter.reset();
71}
72
74{
75 // dimensions of parent window
76 auto nOutputHeight = GetSizePixel().Height();
77 auto nOldSplitPos = m_xHorzSplitter->get_position();
78 auto nSplitPos = nOldSplitPos;
79
80 // shift range of the splitter is the middle third of the output
81 auto nDragPosY = nOutputHeight/3;
82 auto nDragSizeHeight = nOutputHeight/3;
83 if (nSplitPos < nDragPosY || nSplitPos > nDragPosY + nDragSizeHeight)
84 nSplitPos = nDragPosY + nDragSizeHeight;
85
86 // set splitter
87 m_xHorzSplitter->set_position(nSplitPos);
88
90
91 if (nOldSplitPos != nSplitPos)
92 m_xHorzSplitter->set_position(nSplitPos);
93}
94
96{
98
99 // forward the focus to the current cell of the editor control
100 if (m_xEditorCtrl)
101 m_xEditorCtrl->GrabFocus();
102}
103
105 const Reference< XComponentContext >& _rxOrb,
106 OTableController& _rController
107 ) :
108 ODataView( pParent, _rController,_rxOrb )
109 ,m_rController( _rController )
110 ,m_eChildFocus(NONE)
111{
112
113 try
114 {
116 }
117 catch(Exception&)
118 {
119 }
120
122
123 m_pWin->GetDescWin()->connect_focus_in(LINK(this, OTableDesignView, FieldDescFocusIn));
124
125 m_pWin->Show();
126}
127
129{
130 disposeOnce();
131}
132
134{
135 m_pWin->Hide();
136 m_pWin.disposeAndClear();
138}
139
141{
142 GetEditorCtrl()->Init();
143 GetDescWin()->Init();
144 // first call after the editctrl has been set
145
146 GetEditorCtrl()->Show();
147 GetDescWin()->Show();
148
150}
151
153{
154 m_pWin->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
155
156 // just for completeness: there is no space left, we occupied it all ...
157 _rPlayground.SetPos( _rPlayground.BottomRight() );
158 _rPlayground.SetSize( Size( 0, 0 ) );
159}
160
161IMPL_LINK_NOARG(OTableDesignView, FieldDescFocusIn, weld::Widget&, void)
162{
163 m_eChildFocus = DESCRIPTION;
164}
165
167{
168 if (rNEvt.GetType() == NotifyEventType::GETFOCUS)
169 {
172 else if ( GetEditorCtrl() && GetEditorCtrl()->HasChildPathFocus() )
174 else
176 }
177
178 return ODataView::PreNotify(rNEvt);
179}
180
182{
183 IClipboardTest* pTest = nullptr;
184 switch(m_eChildFocus)
185 {
186 case DESCRIPTION:
187 pTest = GetDescWin();
188 break;
189 case EDITOR:
190 pTest = GetEditorCtrl();
191 break;
192 case NONE:
193 break;
194 }
195 return pTest;
196}
197
199{
201 return pTest && pTest->isCopyAllowed();
202}
203
205{
207 return pTest && pTest->isCutAllowed();
208}
209
211{
213 return pTest && pTest->isPasteAllowed();
214}
215
217{
219 if ( pTest )
220 pTest->copy();
221}
222
224{
226 if ( pTest )
227 pTest->cut();
228}
229
231{
233 if ( pTest )
234 pTest->paste();
235}
236
237// set the view readonly or not
238void OTableDesignView::setReadOnly(bool _bReadOnly)
239{
240 GetDescWin()->SetReadOnly(_bReadOnly);
241 GetEditorCtrl()->SetReadOnly(_bReadOnly);
242}
243
245{
247 std::shared_ptr<OTableRow> pRow = (*GetEditorCtrl()->GetRowList())[GetEditorCtrl()->GetCurRow()];
248 OFieldDescription* pFieldDescr = pRow ? pRow->GetActFieldDescr() : nullptr;
249 if ( pFieldDescr )
250 GetDescWin()->DisplayData(pFieldDescr);
251}
252
254{
255 if ( GetEditorCtrl() )
257}
258
259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetCurRow() const
virtual void GrabFocus() override
virtual void Layout()
virtual void dispose() override
virtual void GetFocus() override
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
NotifyEventType GetType() const
constexpr tools::Long Height() const
const LanguageTag & GetLanguageTag() const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void copy()=0
virtual bool isCutAllowed()=0
virtual void cut()=0
virtual bool isPasteAllowed()=0
virtual void paste()=0
virtual bool isCopyAllowed()=0
virtual void dispose() override
Definition: dataview.cxx:58
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: dataview.cxx:96
virtual ~OTableBorderWindow() override
virtual void Layout() override
std::unique_ptr< OTableFieldDescWin > m_xFieldDescWin
virtual void dispose() override
virtual void GetFocus() override
css::uno::Reference< css::awt::XWindow > m_xEditorParentWin
std::unique_ptr< weld::Container > m_xFieldDescParent
std::unique_ptr< weld::Paned > m_xHorzSplitter
std::unique_ptr< weld::Container > m_xEditorParent
VclPtr< OTableEditorCtrl > m_xEditorCtrl
virtual bool isCutAllowed() override
virtual bool isCopyAllowed() override
VclPtr< OTableBorderWindow > m_pWin
virtual void copy() override
virtual void cut() override
IClipboardTest * getActiveChild() const
css::lang::Locale m_aLocale
OTableDesignView(vcl::Window *pParent, const css::uno::Reference< css::uno::XComponentContext > &, OTableController &_rController)
OTableFieldDescWin * GetDescWin() const
virtual void paste() override
void setReadOnly(bool _bReadOnly)
virtual void initialize() override
virtual bool PreNotify(NotifyEvent &rNEvt) override
virtual bool isPasteAllowed() override
ChildFocusState m_eChildFocus
virtual void resizeDocumentView(tools::Rectangle &rRect) override
virtual void GetFocus() override
OTableEditorCtrl * GetEditorCtrl() const
virtual void dispose() override
virtual ~OTableDesignView() override
virtual void DeactivateCell(bool bUpdate=true) override
void SetReadOnly(bool bRead)
void DisplayData(sal_Int32 nRow)
force displaying of the given row
virtual void Init() override
std::vector< std::shared_ptr< OTableRow > > * GetRowList()
void DisplayData(OFieldDescription *pFieldDescr)
void SetReadOnly(bool bReadOnly)
ClassificationCategoriesController & m_rController
void SetSize(const Size &)
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
constexpr Point BottomRight() const
void SetStyle(WinBits nStyle)
bool HasChildPathFocus(bool bSystemWindow=false) const
WinBits GetStyle() const
virtual Size GetSizePixel() const
constexpr OUStringLiteral HID_TAB_DESIGN_DESCWIN
Definition: helpids.h:44
NONE
@ Exception
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
WinBits const WB_DIALOGCONTROL