xref: /trunk/main/dbaccess/source/ui/tabledesign/TEditControl.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
12e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52e2212a7SAndrew Rist  * distributed with this work for additional information
62e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
82e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
92e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
112e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
132e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
142e2212a7SAndrew Rist  * software distributed under the License is distributed on an
152e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
172e2212a7SAndrew Rist  * specific language governing permissions and limitations
182e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
202e2212a7SAndrew Rist  *************************************************************/
212e2212a7SAndrew Rist 
222e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_TABLEEDITORCONTROL_HXX
24cdf0e10cSrcweir #define DBAUI_TABLEEDITORCONTROL_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNCONTROL_HXX
27cdf0e10cSrcweir #include "TableDesignControl.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNVIEW_HXX
30cdf0e10cSrcweir #include "TableDesignView.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
33cdf0e10cSrcweir #include "TableFieldDescWin.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef DBAUI_TABLEROW_HXX
36cdf0e10cSrcweir #include "TableRow.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef DBAUI_ENUMTYPES_HXX
39cdf0e10cSrcweir #include "QEnumTypes.hxx"
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef DBAUI_TYPEINFO_HXX
42cdf0e10cSrcweir #include "TypeInfo.hxx"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class Edit;
46cdf0e10cSrcweir class SfxUndoManager;
47cdf0e10cSrcweir namespace dbaui
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     class OSQLNameEdit;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     class OTableEditorCtrl : public OTableRowView
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir         enum ChildFocusState
54cdf0e10cSrcweir         {
55cdf0e10cSrcweir             HELPTEXT,
56cdf0e10cSrcweir             DESCRIPTION,
57cdf0e10cSrcweir             NAME,
58cdf0e10cSrcweir             ROW,
59cdf0e10cSrcweir             NONE
60cdf0e10cSrcweir         };
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         ::std::vector< ::boost::shared_ptr<OTableRow> > m_aUndoList;
63cdf0e10cSrcweir         ::std::vector< ::boost::shared_ptr<OTableRow> >*    m_pRowList;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         OSQLNameEdit*               pNameCell;
66cdf0e10cSrcweir         ::svt::ListBoxControl*      pTypeCell;
67cdf0e10cSrcweir         Edit*                       pHelpTextCell;
68cdf0e10cSrcweir         Edit*                       pDescrCell;
69cdf0e10cSrcweir         OTableFieldDescWin*         pDescrWin;          // properties of one column
70cdf0e10cSrcweir 
71cdf0e10cSrcweir          ::boost::shared_ptr<OTableRow> pActRow;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         sal_uLong                       nIndexEvent;
74cdf0e10cSrcweir         sal_uLong                       nCutEvent;
75cdf0e10cSrcweir         sal_uLong                       nPasteEvent;
76cdf0e10cSrcweir         sal_uLong                       nDeleteEvent;
77cdf0e10cSrcweir         sal_uLong                       nInsNewRowsEvent;
78cdf0e10cSrcweir         sal_uLong                       nInvalidateTypeEvent;
79cdf0e10cSrcweir         sal_uLong                       nEntryNotFoundEvent;
80cdf0e10cSrcweir         ChildFocusState             m_eChildFocus;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         long nOldDataPos;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         sal_Bool bSaveOnMove;
85cdf0e10cSrcweir         sal_Bool bReadOnly;
86cdf0e10cSrcweir         //------------------------------------------------------------------
87cdf0e10cSrcweir         // Hilfsklasse
88cdf0e10cSrcweir         class ClipboardInvalidator
89cdf0e10cSrcweir         {
90cdf0e10cSrcweir         private:
91cdf0e10cSrcweir             AutoTimer   m_aInvalidateTimer;
92cdf0e10cSrcweir             OTableEditorCtrl* m_pOwner;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         public:
95cdf0e10cSrcweir             ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl*);
96cdf0e10cSrcweir             ~ClipboardInvalidator();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         protected:
99cdf0e10cSrcweir             DECL_LINK(OnInvalidate, void*);
100cdf0e10cSrcweir         };
101cdf0e10cSrcweir         friend class OTableEditorCtrl::ClipboardInvalidator;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         ClipboardInvalidator    m_aInvalidate;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     protected:
106cdf0e10cSrcweir         virtual void Command( const CommandEvent& rEvt );
107cdf0e10cSrcweir         virtual sal_Bool SeekRow(long nRow);
108cdf0e10cSrcweir         virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect,
109cdf0e10cSrcweir                                sal_uInt16 nColumnId ) const;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         virtual void CursorMoved();
112cdf0e10cSrcweir         virtual RowStatus GetRowStatus(long nRow) const;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol);
115cdf0e10cSrcweir         virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         virtual void CellModified();
118cdf0e10cSrcweir         virtual sal_Bool SaveModified();    // wird aufgerufen vor einem Zellenwechsel
119cdf0e10cSrcweir                                         // return sal_False, verhindert Zellenwechsel
120cdf0e10cSrcweir         virtual void Undo();
121cdf0e10cSrcweir         virtual void Redo();
122cdf0e10cSrcweir         virtual String GetCellText(long nRow, sal_uInt16 nColId) const;
123cdf0e10cSrcweir         virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         virtual void CopyRows();
126cdf0e10cSrcweir         virtual void InsertRows( long nRow );
127cdf0e10cSrcweir         virtual void DeleteRows();
128cdf0e10cSrcweir         virtual void InsertNewRows( long nRow );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         virtual sal_Bool IsPrimaryKeyAllowed( long nRow );
131cdf0e10cSrcweir         virtual sal_Bool IsInsertNewAllowed( long nRow );
132cdf0e10cSrcweir         virtual sal_Bool IsDeleteAllowed( long nRow );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         void         ClearModified();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         void         SetPrimaryKey( sal_Bool bSet );
137cdf0e10cSrcweir         sal_Bool         IsPrimaryKey();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         DECL_LINK(ControlPreNotifyHdl, NotifyEvent*);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     public:
142cdf0e10cSrcweir         //  TYPEINFO();
143cdf0e10cSrcweir         OTableEditorCtrl(Window* pParentWin);
144cdf0e10cSrcweir         virtual         ~OTableEditorCtrl();
145cdf0e10cSrcweir         virtual sal_Bool    CursorMoving(long nNewRow, sal_uInt16 nNewCol);
146cdf0e10cSrcweir         virtual void    UpdateAll();
147cdf0e10cSrcweir         SfxUndoManager& GetUndoManager() const;
148cdf0e10cSrcweir 
SetDescrWin(OTableFieldDescWin * pWin)149cdf0e10cSrcweir         void            SetDescrWin( OTableFieldDescWin* pWin ){ pDescrWin = pWin; if (pDescrWin && pActRow) pDescrWin->DisplayData(pActRow->GetActFieldDescr()); }
150cdf0e10cSrcweir         sal_Bool            SaveCurRow();
151cdf0e10cSrcweir         void            SwitchType( const TOTypeInfoSP& _pType );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         void            DisplayData( long nRow, sal_Bool bGrabFocus = sal_True );
154cdf0e10cSrcweir             // erzwingt das Anzeigen der genannten Zeile (selbst wenn es eigentlich schon die aktuelle ist)
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         virtual void    SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo );
157cdf0e10cSrcweir         virtual void    SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rSaveData );
158cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any  GetCellData( long nRow, sal_uInt16 nColId );
159cdf0e10cSrcweir         virtual void    SetControlText( long nRow, sal_uInt16 nColId, const String& rText );
160cdf0e10cSrcweir         virtual String  GetControlText( long nRow, sal_uInt16 nColId );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir         virtual OTableDesignView* GetView() const;
163cdf0e10cSrcweir 
GetRowList()164cdf0e10cSrcweir         ::std::vector< ::boost::shared_ptr<OTableRow> >* GetRowList(){ return m_pRowList; }
165cdf0e10cSrcweir 
GetActRow()166cdf0e10cSrcweir         ::boost::shared_ptr<OTableRow>         GetActRow(){ return pActRow; }
167cdf0e10cSrcweir         void            CellModified( long nRow, sal_uInt16 nColId );
168cdf0e10cSrcweir         void            SetReadOnly( sal_Bool bRead=sal_True );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         virtual void Init();
171cdf0e10cSrcweir         virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         sal_Bool IsCutAllowed( long nRow = -1 );
174cdf0e10cSrcweir         sal_Bool IsCopyAllowed( long nRow = -1 );
175cdf0e10cSrcweir         sal_Bool IsPasteAllowed( long nRow = -1 );
176cdf0e10cSrcweir         sal_Bool IsReadOnly();
177cdf0e10cSrcweir         OFieldDescription* GetFieldDescr( long nRow );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir         // window overloads
180cdf0e10cSrcweir         virtual long            PreNotify( NotifyEvent& rNEvt );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         // IClipboardTest
isCutAllowed()183cdf0e10cSrcweir         virtual sal_Bool isCutAllowed() { return IsCutAllowed(); }
isCopyAllowed()184cdf0e10cSrcweir         virtual sal_Bool isCopyAllowed() { return IsCopyAllowed(); }
isPasteAllowed()185cdf0e10cSrcweir         virtual sal_Bool isPasteAllowed() { return IsPasteAllowed(); }
hasChildPathFocus()186cdf0e10cSrcweir         virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir         virtual void cut();
189cdf0e10cSrcweir         virtual void copy();
190cdf0e10cSrcweir         virtual void paste();
191cdf0e10cSrcweir     private:
192cdf0e10cSrcweir         DECL_LINK( StartIndexing, void* );
193cdf0e10cSrcweir         DECL_LINK( DelayedCut, void* );
194cdf0e10cSrcweir         DECL_LINK( DelayedPaste, void* );
195cdf0e10cSrcweir         DECL_LINK( DelayedDelete, void* );
196cdf0e10cSrcweir         DECL_LINK( DelayedInsNewRows, void* );
197cdf0e10cSrcweir         DECL_LINK( InvalidateFieldType, void* );
198cdf0e10cSrcweir         DECL_LINK( EntryNotFound, void* );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir         void InitCellController();
201cdf0e10cSrcweir         sal_Int32 HasFieldName( const String& rFieldName );
202cdf0e10cSrcweir         String GenerateName( const String& rName );
203cdf0e10cSrcweir         sal_Bool SetDataPtr( long nRow );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         sal_Bool SaveData(long nRow, sal_uInt16 nColumnId);
206cdf0e10cSrcweir         /** AdjustFieldDescription set the needed values for the description
207cdf0e10cSrcweir             @param  _pFieldDesc     the field description where to set the values
208*300d4866SJohn Bampton             @param  _rMultiSel      contains the positions which changed for undo/redo
209cdf0e10cSrcweir             @param  _nPos           the current position
210cdf0e10cSrcweir             @param  _bSet           should a key be set
211cdf0e10cSrcweir             @param  _bPrimaryKey    which value should the pkey have
212cdf0e10cSrcweir         */
213cdf0e10cSrcweir         void AdjustFieldDescription( OFieldDescription* _pFieldDesc,
214cdf0e10cSrcweir                                      MultiSelection& _rMultiSel,
215cdf0e10cSrcweir                                      sal_Int32 _nPos,
216cdf0e10cSrcweir                                      sal_Bool _bSet,
217cdf0e10cSrcweir                                      sal_Bool _bPrimaryKey);
218cdf0e10cSrcweir         /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC
219cdf0e10cSrcweir         */
220cdf0e10cSrcweir         void InvalidateFeatures();
221cdf0e10cSrcweir 
222cdf0e10cSrcweir         void resetType();
223cdf0e10cSrcweir     };
224cdf0e10cSrcweir }
225cdf0e10cSrcweir #endif // DBAUI_TABLEEDITORCONTROL_HXX
226