fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / tabledesign / TEditControl.hxx
blobb56e8d8bb666c42784b23e568b84ca01b36aff14
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 #ifndef INCLUDED_DBACCESS_SOURCE_UI_TABLEDESIGN_TEDITCONTROL_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_TABLEDESIGN_TEDITCONTROL_HXX
22 #include "TableDesignControl.hxx"
23 #include "TableDesignView.hxx"
24 #include "TableFieldDescWin.hxx"
25 #include "TableRow.hxx"
26 #include "QEnumTypes.hxx"
27 #include "TypeInfo.hxx"
29 class Edit;
30 class SfxUndoManager;
31 namespace dbaui
33 class OSQLNameEdit;
35 class OTableEditorCtrl : public OTableRowView
37 enum ChildFocusState
39 HELPTEXT,
40 DESCRIPTION,
41 NAME,
42 ROW,
43 NONE
46 ::std::vector< ::boost::shared_ptr<OTableRow> > m_aUndoList;
47 ::std::vector< ::boost::shared_ptr<OTableRow> >* m_pRowList;
49 VclPtr<OSQLNameEdit> pNameCell;
50 VclPtr< ::svt::ListBoxControl> pTypeCell;
51 VclPtr<Edit> pHelpTextCell;
52 VclPtr<Edit> pDescrCell;
53 VclPtr<OTableFieldDescWin> pDescrWin; // properties of one column
55 ::boost::shared_ptr<OTableRow> pActRow;
57 ImplSVEvent * nCutEvent;
58 ImplSVEvent * nPasteEvent;
59 ImplSVEvent * nDeleteEvent;
60 ImplSVEvent * nInsNewRowsEvent;
61 ImplSVEvent * nInvalidateTypeEvent;
62 ChildFocusState m_eChildFocus;
64 long nOldDataPos;
66 bool bSaveOnMove;
67 bool bReadOnly;
69 // helper class
70 class ClipboardInvalidator
72 private:
73 AutoTimer m_aInvalidateTimer;
74 VclPtr<OTableEditorCtrl> m_pOwner;
76 public:
77 ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl*);
78 ~ClipboardInvalidator();
79 void Stop();
81 protected:
82 DECL_LINK_TYPED(OnInvalidate, Timer*, void);
85 friend class OTableEditorCtrl::ClipboardInvalidator;
87 ClipboardInvalidator m_aInvalidate;
89 protected:
90 virtual void Command( const CommandEvent& rEvt ) SAL_OVERRIDE;
91 virtual bool SeekRow(long nRow) SAL_OVERRIDE;
92 virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect,
93 sal_uInt16 nColumnId ) const SAL_OVERRIDE;
95 virtual void CursorMoved() SAL_OVERRIDE;
96 virtual RowStatus GetRowStatus(long nRow) const SAL_OVERRIDE;
98 virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol) SAL_OVERRIDE;
99 virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol) SAL_OVERRIDE;
101 virtual void CellModified() SAL_OVERRIDE;
102 virtual bool SaveModified() SAL_OVERRIDE; // is called before changing a cell (false prevents change)
104 virtual OUString GetCellText(long nRow, sal_uInt16 nColId) const SAL_OVERRIDE;
105 virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId) SAL_OVERRIDE;
107 virtual void CopyRows() SAL_OVERRIDE;
108 virtual void InsertRows( long nRow ) SAL_OVERRIDE;
109 virtual void DeleteRows() SAL_OVERRIDE;
110 virtual void InsertNewRows( long nRow ) SAL_OVERRIDE;
112 virtual bool IsPrimaryKeyAllowed( long nRow ) SAL_OVERRIDE;
113 virtual bool IsInsertNewAllowed( long nRow ) SAL_OVERRIDE;
114 virtual bool IsDeleteAllowed( long nRow ) SAL_OVERRIDE;
116 void ClearModified();
118 void SetPrimaryKey( bool bSet );
119 bool IsPrimaryKey();
121 DECL_LINK(ControlPreNotifyHdl, NotifyEvent*);
123 public:
124 OTableEditorCtrl(vcl::Window* pParentWin);
125 virtual ~OTableEditorCtrl();
126 virtual void dispose() SAL_OVERRIDE;
127 virtual bool CursorMoving(long nNewRow, sal_uInt16 nNewCol) SAL_OVERRIDE;
128 SfxUndoManager& GetUndoManager() const;
130 void SetDescrWin( OTableFieldDescWin* pWin )
132 pDescrWin = pWin;
133 if (pDescrWin && pActRow)
134 pDescrWin->DisplayData(pActRow->GetActFieldDescr());
136 bool SaveCurRow();
137 void SwitchType( const TOTypeInfoSP& _pType );
139 /// force displaying of the given row
140 void DisplayData( long nRow, bool bGrabFocus = true );
142 virtual void SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo ) SAL_OVERRIDE;
143 virtual void SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rSaveData ) SAL_OVERRIDE;
144 virtual ::com::sun::star::uno::Any GetCellData( long nRow, sal_uInt16 nColId ) SAL_OVERRIDE;
145 virtual void SetControlText( long nRow, sal_uInt16 nColId, const OUString& rText ) SAL_OVERRIDE;
146 virtual OUString GetControlText( long nRow, sal_uInt16 nColId ) SAL_OVERRIDE;
148 virtual OTableDesignView* GetView() const SAL_OVERRIDE;
150 ::std::vector< ::boost::shared_ptr<OTableRow> >* GetRowList(){ return m_pRowList; }
152 ::boost::shared_ptr<OTableRow> GetActRow(){ return pActRow; }
153 void CellModified( long nRow, sal_uInt16 nColId );
154 void SetReadOnly( bool bRead=true );
156 virtual void Init() SAL_OVERRIDE;
157 virtual void DeactivateCell(bool bUpdate = true) SAL_OVERRIDE;
159 bool IsCutAllowed( long nRow = -1 );
160 bool IsCopyAllowed( long nRow = -1 );
161 bool IsPasteAllowed( long nRow = -1 );
162 bool IsReadOnly() { return bReadOnly;}
163 OFieldDescription* GetFieldDescr( long nRow );
165 // Window overrides
166 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
168 // IClipboardTest
169 virtual bool isCutAllowed() SAL_OVERRIDE { return IsCutAllowed(); }
170 virtual bool isCopyAllowed() SAL_OVERRIDE { return IsCopyAllowed(); }
171 virtual bool isPasteAllowed() SAL_OVERRIDE { return IsPasteAllowed(); }
172 virtual bool hasChildPathFocus() SAL_OVERRIDE { return HasChildPathFocus(); }
174 virtual void cut() SAL_OVERRIDE;
175 virtual void copy() SAL_OVERRIDE;
176 virtual void paste() SAL_OVERRIDE;
178 private:
179 DECL_LINK( StartIndexing, void* );
180 DECL_LINK( DelayedCut, void* );
181 DECL_LINK( DelayedPaste, void* );
182 DECL_LINK( DelayedDelete, void* );
183 DECL_LINK( DelayedInsNewRows, void* );
184 DECL_LINK( InvalidateFieldType, void* );
186 void InitCellController();
187 sal_Int32 HasFieldName( const OUString& rFieldName );
188 OUString GenerateName( const OUString& rName );
189 bool SetDataPtr( long nRow );
191 bool SaveData(long nRow, sal_uInt16 nColumnId);
192 /** AdjustFieldDescription set the needed values for the description
193 @param _pFieldDesc the field description where to set the values
194 @param _rMultiSel contains the positions which changed for undo/redo
195 @param _nPos the current position
196 @param _bSet should a key be set
197 @param _bPrimaryKey which value should the pkey have
199 void AdjustFieldDescription( OFieldDescription* _pFieldDesc,
200 MultiSelection& _rMultiSel,
201 sal_Int32 _nPos,
202 bool _bSet,
203 bool _bPrimaryKey);
204 /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC
206 void InvalidateFeatures();
208 void resetType();
211 #endif // INCLUDED_DBACCESS_SOURCE_UI_TABLEDESIGN_TEDITCONTROL_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */