LibreOffice Module dbaccess (master) 1
TEditControl.hxx
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#pragma once
20
22#include <TableDesignView.hxx>
23#include "TableFieldDescWin.hxx"
24#include <TableRow.hxx>
25#include <TypeInfo.hxx>
26
27class Edit;
28class SfxUndoManager;
29namespace dbaui
30{
31 class OSQLNameEditControl;
32
34 {
36 {
41 NONE
42 };
43
44 std::vector< std::shared_ptr<OTableRow> >* m_pRowList;
45
51 OTableFieldDescWin* pDescrWin; // properties of one column
52
53 std::shared_ptr<OTableRow> pActRow;
54
61
63
65
66 // helper class
68 {
69 private:
72
73 public:
76 void Stop();
77
78 private:
79 DECL_LINK(OnInvalidate, Timer*, void);
80 };
81
83
85
86 protected:
87 virtual void Command( const CommandEvent& rEvt ) override;
88 virtual bool SeekRow(sal_Int32 nRow) override;
89 virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect,
90 sal_uInt16 nColumnId ) const override;
91
92 virtual void CursorMoved() override;
93 virtual RowStatus GetRowStatus(sal_Int32 nRow) const override;
94
95 virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override;
96 virtual void InitController(::svt::CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol) override;
97
98 virtual void CellModified() override;
99 virtual bool SaveModified() override; // is called before changing a cell (false prevents change)
100
101 virtual OUString GetCellText(sal_Int32 nRow, sal_uInt16 nColId) const override;
102 virtual sal_uInt32 GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId) override;
103
104 virtual void CopyRows() override;
105 virtual void InsertRows( sal_Int32 nRow ) override;
106 virtual void DeleteRows() override;
107 virtual void InsertNewRows( sal_Int32 nRow ) override;
108
109 virtual bool IsPrimaryKeyAllowed() override;
110 virtual bool IsInsertNewAllowed( sal_Int32 nRow ) override;
111 virtual bool IsDeleteAllowed() override;
112
113 void ClearModified();
114
115 void SetPrimaryKey( bool bSet );
116 bool IsPrimaryKey();
117
118 public:
119 explicit OTableEditorCtrl(vcl::Window* pParentWin, OTableDesignView* pView);
120 virtual ~OTableEditorCtrl() override;
121 virtual void dispose() override;
122 virtual bool CursorMoving(sal_Int32 nNewRow, sal_uInt16 nNewCol) override;
124
126 {
127 pDescrWin = pWin;
128 if (pDescrWin && pActRow)
129 pDescrWin->DisplayData(pActRow->GetActFieldDescr());
130 }
131 void SaveCurRow();
132 void SwitchType( const TOTypeInfoSP& _pType );
133
135 void DisplayData( sal_Int32 nRow );
136
137 virtual void SetCellData( sal_Int32 nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo ) override;
138 virtual void SetCellData( sal_Int32 nRow, sal_uInt16 nColId, const css::uno::Any& _rSaveData ) override;
139 virtual css::uno::Any GetCellData( sal_Int32 nRow, sal_uInt16 nColId ) override;
140 virtual void SetControlText( sal_Int32 nRow, sal_uInt16 nColId, const OUString& rText ) override;
141
142 virtual OTableDesignView* GetView() const override;
143
144 std::vector< std::shared_ptr<OTableRow> >* GetRowList(){ return m_pRowList; }
145
146 const std::shared_ptr<OTableRow>& GetActRow() const { return pActRow; }
147 void CellModified( sal_Int32 nRow, sal_uInt16 nColId );
148 void SetReadOnly( bool bRead );
149
150 virtual void Init() override;
151 virtual void DeactivateCell(bool bUpdate = true) override;
152
153 bool IsCutAllowed();
154 bool IsCopyAllowed();
155 bool IsPasteAllowed() const;
156 bool IsReadOnly() const { return bReadOnly;}
157 OFieldDescription* GetFieldDescr( sal_Int32 nRow );
158
159 // Window overrides
160 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
161
162 // IClipboardTest
163 virtual bool isCutAllowed() override { return IsCutAllowed(); }
164 virtual bool isCopyAllowed() override { return IsCopyAllowed(); }
165 virtual bool isPasteAllowed() override { return IsPasteAllowed(); }
166
167 virtual void cut() override;
168 virtual void copy() override;
169 virtual void paste() override;
170
171 private:
172 DECL_LINK( DelayedCut, void*, void );
173 DECL_LINK( DelayedPaste, void*, void );
174 DECL_LINK( DelayedDelete, void*, void );
175 DECL_LINK( DelayedInsNewRows, void*, void );
176 DECL_LINK( InvalidateFieldType, void*, void );
177
178 void InitCellController();
179 sal_Int32 HasFieldName( std::u16string_view rFieldName );
180 OUString GenerateName( const OUString& rName );
181 bool SetDataPtr( sal_Int32 nRow );
182
183 void SaveData(sal_Int32 nRow, sal_uInt16 nColumnId);
191 void AdjustFieldDescription( OFieldDescription* _pFieldDesc,
192 MultiSelection& _rMultiSel,
193 sal_Int32 _nPos,
194 bool _bSet,
195 bool _bPrimaryKey);
198 void InvalidateFeatures();
199
200 void resetType();
201 };
202}
203
204/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DECL_LINK(OnInvalidate, Timer *, void)
virtual void paste() override
VclPtr<::svt::EditControl > pDescrCell
virtual OUString GetCellText(sal_Int32 nRow, sal_uInt16 nColId) const override
void InvalidateFeatures()
InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC.
OFieldDescription * GetFieldDescr(sal_Int32 nRow)
virtual void copy() override
virtual void SetControlText(sal_Int32 nRow, sal_uInt16 nColId, const OUString &rText) override
virtual ~OTableEditorCtrl() override
ClipboardInvalidator m_aInvalidate
virtual void PaintCell(OutputDevice &rDev, const tools::Rectangle &rRect, sal_uInt16 nColumnId) const override
OTableFieldDescWin * pDescrWin
virtual void CellModified() override
virtual bool IsDeleteAllowed() override
ImplSVEvent * nInsNewRowsEvent
VclPtr<::svt::ListBoxControl > pTypeCell
virtual bool isCopyAllowed() override
VclPtr< OSQLNameEditControl > pNameCell
virtual void CopyRows() override
virtual bool SeekRow(sal_Int32 nRow) override
SfxUndoManager & GetUndoManager() const
void SaveData(sal_Int32 nRow, sal_uInt16 nColumnId)
virtual void SetCellData(sal_Int32 nRow, sal_uInt16 nColId, const css::uno::Any &_rSaveData) override
VclPtr<::svt::EditControl > pHelpTextCell
virtual ::svt::CellController * GetController(sal_Int32 nRow, sal_uInt16 nCol) override
virtual void InitController(::svt::CellControllerRef &rController, sal_Int32 nRow, sal_uInt16 nCol) override
DECL_LINK(DelayedInsNewRows, void *, void)
const std::shared_ptr< OTableRow > & GetActRow() const
void AdjustFieldDescription(OFieldDescription *_pFieldDesc, MultiSelection &_rMultiSel, sal_Int32 _nPos, bool _bSet, bool _bPrimaryKey)
AdjustFieldDescription set the needed values for the description.
virtual void DeactivateCell(bool bUpdate=true) override
void SetDescrWin(OTableFieldDescWin *pWin)
virtual bool SaveModified() override
DECL_LINK(DelayedCut, void *, void)
virtual bool IsPrimaryKeyAllowed() override
virtual sal_uInt32 GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId) override
virtual RowStatus GetRowStatus(sal_Int32 nRow) const override
virtual bool CursorMoving(sal_Int32 nNewRow, sal_uInt16 nNewCol) override
DECL_LINK(InvalidateFieldType, void *, void)
void SwitchType(const TOTypeInfoSP &_pType)
void SetReadOnly(bool bRead)
virtual void dispose() override
virtual void CursorMoved() override
void SetPrimaryKey(bool bSet)
virtual void Command(const CommandEvent &rEvt) override
virtual void DeleteRows() override
virtual void SetCellData(sal_Int32 nRow, sal_uInt16 nColId, const TOTypeInfoSP &_pTypeInfo) override
virtual void InsertRows(sal_Int32 nRow) override
ImplSVEvent * nPasteEvent
ChildFocusState m_eChildFocus
ImplSVEvent * nInvalidateTypeEvent
OTableEditorCtrl(vcl::Window *pParentWin, OTableDesignView *pView)
void DisplayData(sal_Int32 nRow)
force displaying of the given row
virtual bool isPasteAllowed() override
DECL_LINK(DelayedDelete, void *, void)
VclPtr< OTableDesignView > m_pView
virtual css::uno::Any GetCellData(sal_Int32 nRow, sal_uInt16 nColId) override
sal_Int32 HasFieldName(std::u16string_view rFieldName)
virtual bool IsInsertNewAllowed(sal_Int32 nRow) override
bool SetDataPtr(sal_Int32 nRow)
virtual void Init() override
virtual void cut() override
OUString GenerateName(const OUString &rName)
std::shared_ptr< OTableRow > pActRow
virtual bool PreNotify(NotifyEvent &rNEvt) override
DECL_LINK(DelayedPaste, void *, void)
virtual void InsertNewRows(sal_Int32 nRow) override
virtual OTableDesignView * GetView() const override
virtual bool isCutAllowed() override
std::vector< std::shared_ptr< OTableRow > > * m_pRowList
std::vector< std::shared_ptr< OTableRow > > * GetRowList()
ImplSVEvent * nDeleteEvent
void DisplayData(OFieldDescription *pFieldDescr)
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99
long Long