1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX 28 #define DBAUI_QUERYDESIGNFIELDUNDOACT_HXX 29 30 #ifndef DBAUI_GENERALUNDO_HXX 31 #include "GeneralUndo.hxx" 32 #endif 33 #ifndef _DBU_QRY_HRC_ 34 #include "dbu_qry.hrc" 35 #endif 36 #ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX 37 #include "SelectionBrowseBox.hxx" 38 #endif 39 40 41 namespace dbaui 42 { 43 // ================================================================================================ 44 // OQueryDesignFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf 45 46 47 class OQueryDesignFieldUndoAct : public OCommentUndoAction 48 { 49 protected: 50 OSelectionBrowseBox* pOwner; 51 sal_uInt16 m_nColumnPostion; 52 53 virtual void Undo() = 0; 54 virtual void Redo() = 0; 55 56 public: 57 OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID); 58 virtual ~OQueryDesignFieldUndoAct(); 59 60 inline void SetColumnPosition(sal_uInt16 _nColumnPostion) 61 { 62 m_nColumnPostion = _nColumnPostion; 63 OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!"); 64 OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!"); 65 } 66 }; 67 68 // ================================================================================================ 69 // OTabFieldCellModifiedUndoAct - Undo-Klasse fuer Aendern einer Zelle einer Spaltenbeschreibung 70 71 class OTabFieldCellModifiedUndoAct : public OQueryDesignFieldUndoAct 72 { 73 protected: 74 String m_strNextCellContents; 75 sal_Int32 m_nCellIndex; 76 77 public: 78 OTabFieldCellModifiedUndoAct(OSelectionBrowseBox* pSelBrwBox) 79 : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL) 80 ,m_nCellIndex(BROWSER_INVALIDID){ } 81 82 inline void SetCellContents(const String& str) { m_strNextCellContents = str; } 83 inline void SetCellIndex(sal_Int32 nIndex) { m_nCellIndex = nIndex; } 84 85 virtual void Undo(); 86 virtual void Redo() { Undo(); } 87 }; 88 89 // ================================================================================================ 90 // OTabFieldSizedUndoAct - Undo-Klasse fuer Aendern einer Spaltenbreite 91 92 class OTabFieldSizedUndoAct : public OQueryDesignFieldUndoAct 93 { 94 protected: 95 long m_nNextWidth; 96 97 public: 98 OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { } 99 100 inline void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; } 101 102 virtual void Undo(); 103 virtual void Redo() { Undo(); } 104 }; 105 106 // ================================================================================================ 107 // OTabFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf, die mit Veraendern einer kompletten Feldbeschreibung zu tun haben 108 109 class OTabFieldUndoAct : public OQueryDesignFieldUndoAct 110 { 111 protected: 112 OTableFieldDescRef pDescr; // geloeschte Spaltenbeschreibung 113 114 public: 115 OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, nCommentID) { } 116 117 void SetTabFieldDescr(OTableFieldDescRef pDescription) { pDescr = pDescription; } 118 }; 119 120 // ================================================================================================ 121 // OTabFieldDelUndoAct - Undo-Klasse fuer Loeschen eines Feldes 122 123 class OTabFieldDelUndoAct : public OTabFieldUndoAct 124 { 125 protected: 126 virtual void Undo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode(); } 127 virtual void Redo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); } 128 129 public: 130 OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { } 131 }; 132 133 // ================================================================================================ 134 // OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes 135 136 class OTabFieldCreateUndoAct : public OTabFieldUndoAct 137 { 138 protected: 139 virtual void Undo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();} 140 virtual void Redo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode();} 141 142 public: 143 OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { } 144 }; 145 146 // ================================================================================================ 147 // OTabFieldMovedUndoAct - Undo-class when a field was moved inside the selection 148 149 class OTabFieldMovedUndoAct : public OTabFieldUndoAct 150 { 151 protected: 152 virtual void Undo(); 153 virtual void Redo() 154 { 155 Undo(); 156 } 157 158 public: 159 OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { } 160 }; 161 } 162 #endif // DBAUI_QUERYDESIGNFIELDUNDOACT_HXX 163 164 165 166