1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TEditControl.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_TABLEEDITORCONTROL_HXX
31 #define DBAUI_TABLEEDITORCONTROL_HXX
33 #ifndef DBAUI_TABLEDESIGNCONTROL_HXX
34 #include "TableDesignControl.hxx"
36 #ifndef DBAUI_TABLEDESIGNVIEW_HXX
37 #include "TableDesignView.hxx"
39 #ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
40 #include "TableFieldDescWin.hxx"
42 #ifndef DBAUI_TABLEROW_HXX
43 #include "TableRow.hxx"
45 #ifndef DBAUI_ENUMTYPES_HXX
46 #include "QEnumTypes.hxx"
48 #ifndef DBAUI_TYPEINFO_HXX
49 #include "TypeInfo.hxx"
58 class OTableEditorCtrl
: public OTableRowView
68 ::std::vector
< ::boost::shared_ptr
<OTableRow
> > m_aUndoList
;
69 ::std::vector
< ::boost::shared_ptr
<OTableRow
> >* m_pRowList
;
71 OSQLNameEdit
* pNameCell
;
72 ::svt::ListBoxControl
* pTypeCell
;
74 OTableFieldDescWin
* pDescrWin
; // properties of one column
76 ::boost::shared_ptr
<OTableRow
> pActRow
;
82 ULONG nInsNewRowsEvent
;
83 ULONG nInvalidateTypeEvent
;
84 ULONG nEntryNotFoundEvent
;
85 ChildFocusState m_eChildFocus
;
91 //------------------------------------------------------------------
93 class ClipboardInvalidator
96 AutoTimer m_aInvalidateTimer
;
97 OTableEditorCtrl
* m_pOwner
;
100 ClipboardInvalidator(ULONG nTimeout
,OTableEditorCtrl
*);
101 ~ClipboardInvalidator();
104 DECL_LINK(OnInvalidate
, void*);
106 friend class OTableEditorCtrl::ClipboardInvalidator
;
108 ClipboardInvalidator m_aInvalidate
;
111 virtual void Command( const CommandEvent
& rEvt
);
112 virtual BOOL
SeekRow(long nRow
);
113 virtual void PaintCell(OutputDevice
& rDev
, const Rectangle
& rRect
,
114 USHORT nColumnId
) const;
116 virtual void CursorMoved();
117 virtual RowStatus
GetRowStatus(long nRow
) const;
119 virtual ::svt::CellController
* GetController(long nRow
, USHORT nCol
);
120 virtual void InitController(::svt::CellControllerRef
& rController
, long nRow
, USHORT nCol
);
122 virtual void CellModified();
123 virtual BOOL
SaveModified(); // wird aufgerufen vor einem Zellenwechsel
124 // return FALSE, verhindert Zellenwechsel
127 virtual String
GetCellText(long nRow
, sal_uInt16 nColId
) const;
128 virtual sal_uInt32
GetTotalCellWidth(long nRow
, sal_uInt16 nColId
);
130 virtual void CopyRows();
131 virtual void InsertRows( long nRow
);
132 virtual void DeleteRows();
133 virtual void InsertNewRows( long nRow
);
135 virtual sal_Bool
IsPrimaryKeyAllowed( long nRow
);
136 virtual sal_Bool
IsInsertNewAllowed( long nRow
);
137 virtual sal_Bool
IsDeleteAllowed( long nRow
);
139 void ClearModified();
141 void SetPrimaryKey( BOOL bSet
);
144 DECL_LINK(ControlPreNotifyHdl
, NotifyEvent
*);
148 OTableEditorCtrl(Window
* pParentWin
);
149 virtual ~OTableEditorCtrl();
150 virtual BOOL
CursorMoving(long nNewRow
, USHORT nNewCol
);
151 virtual void UpdateAll();
152 SfxUndoManager
* GetUndoManager() const;
154 void SetDescrWin( OTableFieldDescWin
* pWin
){ pDescrWin
= pWin
; if (pDescrWin
&& pActRow
) pDescrWin
->DisplayData(pActRow
->GetActFieldDescr()); }
156 void SwitchType( const TOTypeInfoSP
& _pType
);
158 void DisplayData( long nRow
, BOOL bGrabFocus
= TRUE
);
159 // erzwingt das Anzeigen der genannten Zeile (selbst wenn es eigentlich schon die aktuelle ist)
161 virtual void SetCellData( long nRow
, sal_uInt16 nColId
, const TOTypeInfoSP
& _pTypeInfo
);
162 virtual void SetCellData( long nRow
, sal_uInt16 nColId
, const ::com::sun::star::uno::Any
& _rSaveData
);
163 virtual ::com::sun::star::uno::Any
GetCellData( long nRow
, sal_uInt16 nColId
);
164 virtual void SetControlText( long nRow
, sal_uInt16 nColId
, const String
& rText
);
165 virtual String
GetControlText( long nRow
, sal_uInt16 nColId
);
167 virtual OTableDesignView
* GetView() const;
169 ::std::vector
< ::boost::shared_ptr
<OTableRow
> >* GetRowList(){ return m_pRowList
; }
171 ::boost::shared_ptr
<OTableRow
> GetActRow(){ return pActRow
; }
172 void CellModified( long nRow
, sal_uInt16 nColId
);
173 void SetReadOnly( BOOL bRead
=TRUE
);
176 virtual void DeactivateCell(sal_Bool bUpdate
= sal_True
);
178 BOOL
IsCutAllowed( long nRow
= -1 );
179 BOOL
IsCopyAllowed( long nRow
= -1 );
180 BOOL
IsPasteAllowed( long nRow
= -1 );
182 OFieldDescription
* GetFieldDescr( long nRow
);
185 virtual long PreNotify( NotifyEvent
& rNEvt
);
188 virtual sal_Bool
isCutAllowed() { return IsCutAllowed(); }
189 virtual sal_Bool
isCopyAllowed() { return IsCopyAllowed(); }
190 virtual sal_Bool
isPasteAllowed() { return IsPasteAllowed(); }
191 virtual sal_Bool
hasChildPathFocus() { return HasChildPathFocus(); }
195 virtual void paste();
197 DECL_LINK( StartIndexing
, void* );
198 DECL_LINK( DelayedCut
, void* );
199 DECL_LINK( DelayedPaste
, void* );
200 DECL_LINK( DelayedDelete
, void* );
201 DECL_LINK( DelayedInsNewRows
, void* );
202 DECL_LINK( InvalidateFieldType
, void* );
203 DECL_LINK( EntryNotFound
, void* );
205 void InitCellController();
206 INT32
HasFieldName( const String
& rFieldName
);
207 String
GenerateName( const String
& rName
);
208 BOOL
SetDataPtr( long nRow
);
210 BOOL
SaveData(long nRow
, USHORT nColumnId
);
211 /** AdjustFieldDescription set the needed values for the description
212 @param _pFieldDesc the field description where to set the values
213 @param _rMultiSel contains the postions which changed for undo/redo
214 @param _nPos the current position
215 @param _bSet should a key be set
216 @param _bPrimaryKey which value should the pkey have
218 void AdjustFieldDescription( OFieldDescription
* _pFieldDesc
,
219 MultiSelection
& _rMultiSel
,
222 sal_Bool _bPrimaryKey
);
223 /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC
225 void InvalidateFeatures();
230 #endif // DBAUI_TABLEEDITORCONTROL_HXX