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 <TableDesignControl.hxx>
22 #include <TableDesignView.hxx>
23 #include "TableFieldDescWin.hxx"
24 #include <TableRow.hxx>
25 #include <TypeInfo.hxx>
31 class OSQLNameEditControl
;
33 class OTableEditorCtrl
: public OTableRowView
44 std::vector
< std::shared_ptr
<OTableRow
> >* m_pRowList
;
46 VclPtr
<OTableDesignView
> m_pView
;
47 VclPtr
<OSQLNameEditControl
> pNameCell
;
48 VclPtr
<::svt::ListBoxControl
> pTypeCell
;
49 VclPtr
<::svt::EditControl
> pHelpTextCell
;
50 VclPtr
<::svt::EditControl
> pDescrCell
;
51 OTableFieldDescWin
* pDescrWin
; // properties of one column
53 std::shared_ptr
<OTableRow
> pActRow
;
55 ImplSVEvent
* nCutEvent
;
56 ImplSVEvent
* nPasteEvent
;
57 ImplSVEvent
* nDeleteEvent
;
58 ImplSVEvent
* nInsNewRowsEvent
;
59 ImplSVEvent
* nInvalidateTypeEvent
;
60 ChildFocusState m_eChildFocus
;
62 tools::Long nOldDataPos
;
67 class ClipboardInvalidator final
70 AutoTimer m_aInvalidateTimer
;
71 VclPtr
<OTableEditorCtrl
> m_pOwner
;
74 explicit ClipboardInvalidator(OTableEditorCtrl
*);
75 ~ClipboardInvalidator();
79 DECL_LINK(OnInvalidate
, Timer
*, void);
82 friend class OTableEditorCtrl::ClipboardInvalidator
;
84 ClipboardInvalidator m_aInvalidate
;
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
;
92 virtual void CursorMoved() override
;
93 virtual RowStatus
GetRowStatus(sal_Int32 nRow
) const override
;
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
;
98 virtual void CellModified() override
;
99 virtual bool SaveModified() override
; // is called before changing a cell (false prevents change)
101 virtual OUString
GetCellText(sal_Int32 nRow
, sal_uInt16 nColId
) const override
;
102 virtual sal_uInt32
GetTotalCellWidth(sal_Int32 nRow
, sal_uInt16 nColId
) override
;
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
;
109 virtual bool IsPrimaryKeyAllowed() override
;
110 virtual bool IsInsertNewAllowed( sal_Int32 nRow
) override
;
111 virtual bool IsDeleteAllowed() override
;
113 void ClearModified();
115 void SetPrimaryKey( bool bSet
);
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
;
123 SfxUndoManager
& GetUndoManager() const;
125 void SetDescrWin( OTableFieldDescWin
* pWin
)
128 if (pDescrWin
&& pActRow
)
129 pDescrWin
->DisplayData(pActRow
->GetActFieldDescr());
132 void SwitchType( const TOTypeInfoSP
& _pType
);
134 /// force displaying of the given row
135 void DisplayData( sal_Int32 nRow
);
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
;
142 virtual OTableDesignView
* GetView() const override
;
144 std::vector
< std::shared_ptr
<OTableRow
> >* GetRowList(){ return m_pRowList
; }
146 const std::shared_ptr
<OTableRow
>& GetActRow() const { return pActRow
; }
147 void CellModified( sal_Int32 nRow
, sal_uInt16 nColId
);
148 void SetReadOnly( bool bRead
);
150 virtual void Init() override
;
151 virtual void DeactivateCell(bool bUpdate
= true) override
;
154 bool IsCopyAllowed();
155 bool IsPasteAllowed() const;
156 bool IsReadOnly() const { return bReadOnly
;}
157 OFieldDescription
* GetFieldDescr( sal_Int32 nRow
);
160 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
163 virtual bool isCutAllowed() override
{ return IsCutAllowed(); }
164 virtual bool isCopyAllowed() override
{ return IsCopyAllowed(); }
165 virtual bool isPasteAllowed() override
{ return IsPasteAllowed(); }
167 virtual void cut() override
;
168 virtual void copy() override
;
169 virtual void paste() override
;
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 );
178 void InitCellController();
179 sal_Int32
HasFieldName( std::u16string_view rFieldName
);
180 OUString
GenerateName( const OUString
& rName
);
181 bool SetDataPtr( sal_Int32 nRow
);
183 void SaveData(sal_Int32 nRow
, sal_uInt16 nColumnId
);
184 /** AdjustFieldDescription set the needed values for the description
185 @param _pFieldDesc the field description where to set the values
186 @param _rMultiSel contains the positions which changed for undo/redo
187 @param _nPos the current position
188 @param _bSet should a key be set
189 @param _bPrimaryKey which value should the pkey have
191 void AdjustFieldDescription( OFieldDescription
* _pFieldDesc
,
192 MultiSelection
& _rMultiSel
,
196 /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC
198 void InvalidateFeatures();
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */