1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef DBAUI_TABLEEDITORCONTROL_HXX 28*cdf0e10cSrcweir #define DBAUI_TABLEEDITORCONTROL_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNCONTROL_HXX 31*cdf0e10cSrcweir #include "TableDesignControl.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNVIEW_HXX 34*cdf0e10cSrcweir #include "TableDesignView.hxx" 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX 37*cdf0e10cSrcweir #include "TableFieldDescWin.hxx" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef DBAUI_TABLEROW_HXX 40*cdf0e10cSrcweir #include "TableRow.hxx" 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef DBAUI_ENUMTYPES_HXX 43*cdf0e10cSrcweir #include "QEnumTypes.hxx" 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef DBAUI_TYPEINFO_HXX 46*cdf0e10cSrcweir #include "TypeInfo.hxx" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir class Edit; 50*cdf0e10cSrcweir class SfxUndoManager; 51*cdf0e10cSrcweir namespace dbaui 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir class OSQLNameEdit; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir class OTableEditorCtrl : public OTableRowView 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir enum ChildFocusState 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir HELPTEXT, 60*cdf0e10cSrcweir DESCRIPTION, 61*cdf0e10cSrcweir NAME, 62*cdf0e10cSrcweir ROW, 63*cdf0e10cSrcweir NONE 64*cdf0e10cSrcweir }; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> > m_aUndoList; 67*cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* m_pRowList; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir OSQLNameEdit* pNameCell; 70*cdf0e10cSrcweir ::svt::ListBoxControl* pTypeCell; 71*cdf0e10cSrcweir Edit* pHelpTextCell; 72*cdf0e10cSrcweir Edit* pDescrCell; 73*cdf0e10cSrcweir OTableFieldDescWin* pDescrWin; // properties of one column 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> pActRow; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir sal_uLong nIndexEvent; 78*cdf0e10cSrcweir sal_uLong nCutEvent; 79*cdf0e10cSrcweir sal_uLong nPasteEvent; 80*cdf0e10cSrcweir sal_uLong nDeleteEvent; 81*cdf0e10cSrcweir sal_uLong nInsNewRowsEvent; 82*cdf0e10cSrcweir sal_uLong nInvalidateTypeEvent; 83*cdf0e10cSrcweir sal_uLong nEntryNotFoundEvent; 84*cdf0e10cSrcweir ChildFocusState m_eChildFocus; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir long nOldDataPos; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir sal_Bool bSaveOnMove; 89*cdf0e10cSrcweir sal_Bool bReadOnly; 90*cdf0e10cSrcweir //------------------------------------------------------------------ 91*cdf0e10cSrcweir // Hilfsklasse 92*cdf0e10cSrcweir class ClipboardInvalidator 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir private: 95*cdf0e10cSrcweir AutoTimer m_aInvalidateTimer; 96*cdf0e10cSrcweir OTableEditorCtrl* m_pOwner; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir public: 99*cdf0e10cSrcweir ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl*); 100*cdf0e10cSrcweir ~ClipboardInvalidator(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir protected: 103*cdf0e10cSrcweir DECL_LINK(OnInvalidate, void*); 104*cdf0e10cSrcweir }; 105*cdf0e10cSrcweir friend class OTableEditorCtrl::ClipboardInvalidator; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir ClipboardInvalidator m_aInvalidate; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir protected: 110*cdf0e10cSrcweir virtual void Command( const CommandEvent& rEvt ); 111*cdf0e10cSrcweir virtual sal_Bool SeekRow(long nRow); 112*cdf0e10cSrcweir virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect, 113*cdf0e10cSrcweir sal_uInt16 nColumnId ) const; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir virtual void CursorMoved(); 116*cdf0e10cSrcweir virtual RowStatus GetRowStatus(long nRow) const; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol); 119*cdf0e10cSrcweir virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir virtual void CellModified(); 122*cdf0e10cSrcweir virtual sal_Bool SaveModified(); // wird aufgerufen vor einem Zellenwechsel 123*cdf0e10cSrcweir // return sal_False, verhindert Zellenwechsel 124*cdf0e10cSrcweir virtual void Undo(); 125*cdf0e10cSrcweir virtual void Redo(); 126*cdf0e10cSrcweir virtual String GetCellText(long nRow, sal_uInt16 nColId) const; 127*cdf0e10cSrcweir virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir virtual void CopyRows(); 130*cdf0e10cSrcweir virtual void InsertRows( long nRow ); 131*cdf0e10cSrcweir virtual void DeleteRows(); 132*cdf0e10cSrcweir virtual void InsertNewRows( long nRow ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir virtual sal_Bool IsPrimaryKeyAllowed( long nRow ); 135*cdf0e10cSrcweir virtual sal_Bool IsInsertNewAllowed( long nRow ); 136*cdf0e10cSrcweir virtual sal_Bool IsDeleteAllowed( long nRow ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void ClearModified(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void SetPrimaryKey( sal_Bool bSet ); 141*cdf0e10cSrcweir sal_Bool IsPrimaryKey(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir DECL_LINK(ControlPreNotifyHdl, NotifyEvent*); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir public: 146*cdf0e10cSrcweir // TYPEINFO(); 147*cdf0e10cSrcweir OTableEditorCtrl(Window* pParentWin); 148*cdf0e10cSrcweir virtual ~OTableEditorCtrl(); 149*cdf0e10cSrcweir virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol); 150*cdf0e10cSrcweir virtual void UpdateAll(); 151*cdf0e10cSrcweir SfxUndoManager& GetUndoManager() const; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir void SetDescrWin( OTableFieldDescWin* pWin ){ pDescrWin = pWin; if (pDescrWin && pActRow) pDescrWin->DisplayData(pActRow->GetActFieldDescr()); } 154*cdf0e10cSrcweir sal_Bool SaveCurRow(); 155*cdf0e10cSrcweir void SwitchType( const TOTypeInfoSP& _pType ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void DisplayData( long nRow, sal_Bool bGrabFocus = sal_True ); 158*cdf0e10cSrcweir // erzwingt das Anzeigen der genannten Zeile (selbst wenn es eigentlich schon die aktuelle ist) 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir virtual void SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo ); 161*cdf0e10cSrcweir virtual void SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rSaveData ); 162*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any GetCellData( long nRow, sal_uInt16 nColId ); 163*cdf0e10cSrcweir virtual void SetControlText( long nRow, sal_uInt16 nColId, const String& rText ); 164*cdf0e10cSrcweir virtual String GetControlText( long nRow, sal_uInt16 nColId ); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir virtual OTableDesignView* GetView() const; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* GetRowList(){ return m_pRowList; } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> GetActRow(){ return pActRow; } 171*cdf0e10cSrcweir void CellModified( long nRow, sal_uInt16 nColId ); 172*cdf0e10cSrcweir void SetReadOnly( sal_Bool bRead=sal_True ); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir virtual void Init(); 175*cdf0e10cSrcweir virtual void DeactivateCell(sal_Bool bUpdate = sal_True); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir sal_Bool IsCutAllowed( long nRow = -1 ); 178*cdf0e10cSrcweir sal_Bool IsCopyAllowed( long nRow = -1 ); 179*cdf0e10cSrcweir sal_Bool IsPasteAllowed( long nRow = -1 ); 180*cdf0e10cSrcweir sal_Bool IsReadOnly(); 181*cdf0e10cSrcweir OFieldDescription* GetFieldDescr( long nRow ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir // window overloads 184*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // IClipboardTest 187*cdf0e10cSrcweir virtual sal_Bool isCutAllowed() { return IsCutAllowed(); } 188*cdf0e10cSrcweir virtual sal_Bool isCopyAllowed() { return IsCopyAllowed(); } 189*cdf0e10cSrcweir virtual sal_Bool isPasteAllowed() { return IsPasteAllowed(); } 190*cdf0e10cSrcweir virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir virtual void cut(); 193*cdf0e10cSrcweir virtual void copy(); 194*cdf0e10cSrcweir virtual void paste(); 195*cdf0e10cSrcweir private: 196*cdf0e10cSrcweir DECL_LINK( StartIndexing, void* ); 197*cdf0e10cSrcweir DECL_LINK( DelayedCut, void* ); 198*cdf0e10cSrcweir DECL_LINK( DelayedPaste, void* ); 199*cdf0e10cSrcweir DECL_LINK( DelayedDelete, void* ); 200*cdf0e10cSrcweir DECL_LINK( DelayedInsNewRows, void* ); 201*cdf0e10cSrcweir DECL_LINK( InvalidateFieldType, void* ); 202*cdf0e10cSrcweir DECL_LINK( EntryNotFound, void* ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir void InitCellController(); 205*cdf0e10cSrcweir sal_Int32 HasFieldName( const String& rFieldName ); 206*cdf0e10cSrcweir String GenerateName( const String& rName ); 207*cdf0e10cSrcweir sal_Bool SetDataPtr( long nRow ); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir sal_Bool SaveData(long nRow, sal_uInt16 nColumnId); 210*cdf0e10cSrcweir /** AdjustFieldDescription set the needed values for the description 211*cdf0e10cSrcweir @param _pFieldDesc the field description where to set the values 212*cdf0e10cSrcweir @param _rMultiSel contains the postions which changed for undo/redo 213*cdf0e10cSrcweir @param _nPos the current position 214*cdf0e10cSrcweir @param _bSet should a key be set 215*cdf0e10cSrcweir @param _bPrimaryKey which value should the pkey have 216*cdf0e10cSrcweir */ 217*cdf0e10cSrcweir void AdjustFieldDescription( OFieldDescription* _pFieldDesc, 218*cdf0e10cSrcweir MultiSelection& _rMultiSel, 219*cdf0e10cSrcweir sal_Int32 _nPos, 220*cdf0e10cSrcweir sal_Bool _bSet, 221*cdf0e10cSrcweir sal_Bool _bPrimaryKey); 222*cdf0e10cSrcweir /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC 223*cdf0e10cSrcweir */ 224*cdf0e10cSrcweir void InvalidateFeatures(); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir void resetType(); 227*cdf0e10cSrcweir }; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir #endif // DBAUI_TABLEEDITORCONTROL_HXX 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir 233