xref: /AOO41X/main/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx (revision 0aabba3ab117bd1ebf1560f23f52dfa1a54fd4c7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
24 #define DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
25 
26 #ifndef DBAUI_GENERALUNDO_HXX
27 #include "GeneralUndo.hxx"
28 #endif
29 #ifndef _DBU_QRY_HRC_
30 #include "dbu_qry.hrc"
31 #endif
32 #ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
33 #include "SelectionBrowseBox.hxx"
34 #endif
35 
36 
37 namespace dbaui
38 {
39 	// ================================================================================================
40 	// OQueryDesignFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf
41 
42 
43 	class OQueryDesignFieldUndoAct : public OCommentUndoAction
44 	{
45 	protected:
46 		OSelectionBrowseBox*	pOwner;
47 		sal_uInt16					m_nColumnPostion;
48 
49 		virtual void	Undo() = 0;
50 		virtual void	Redo() = 0;
51 
52 	public:
53 		OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID);
54 		virtual ~OQueryDesignFieldUndoAct();
55 
56 		inline void SetColumnPosition(sal_uInt16 _nColumnPostion)
57 		{
58 			m_nColumnPostion = _nColumnPostion;
59 			OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
60 			OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
61 		}
62 	};
63 
64 	// ================================================================================================
65 	// OTabFieldCellModifiedUndoAct - Undo-Klasse fuer Aendern einer Zelle einer Spaltenbeschreibung
66 
67 	class OTabFieldCellModifiedUndoAct : public OQueryDesignFieldUndoAct
68 	{
69 	protected:
70 		String		m_strNextCellContents;
71 		sal_Int32	m_nCellIndex;
72 
73 	public:
74 		OTabFieldCellModifiedUndoAct(OSelectionBrowseBox* pSelBrwBox)
75 			: OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL)
76 			,m_nCellIndex(BROWSER_INVALIDID){ }
77 
78 		inline void SetCellContents(const String& str)	{ m_strNextCellContents = str; }
79 		inline void SetCellIndex(sal_Int32 nIndex)		{ m_nCellIndex = nIndex; }
80 
81 		virtual void Undo();
82 		virtual void Redo() { Undo(); }
83 	};
84 
85 	// ================================================================================================
86 	// OTabFieldSizedUndoAct - Undo-Klasse fuer Aendern einer Spaltenbreite
87 
88 	class OTabFieldSizedUndoAct : public OQueryDesignFieldUndoAct
89 	{
90 	protected:
91 		long		m_nNextWidth;
92 
93 	public:
94 		OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { }
95 
96 		inline void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; }
97 
98 		virtual void Undo();
99 		virtual void Redo() { Undo(); }
100 	};
101 
102 	// ================================================================================================
103 	// OTabFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf, die mit Veraendern einer kompletten Feldbeschreibung zu tun haben
104 
105 	class OTabFieldUndoAct : public OQueryDesignFieldUndoAct
106 	{
107 	protected:
108 		OTableFieldDescRef		pDescr;		// geloeschte Spaltenbeschreibung
109 
110 	public:
111 		OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, nCommentID) { }
112 
113 		void SetTabFieldDescr(OTableFieldDescRef pDescription) { pDescr = pDescription; }
114 	};
115 
116 	// ================================================================================================
117 	// OTabFieldDelUndoAct - Undo-Klasse fuer Loeschen eines Feldes
118 
119 	class OTabFieldDelUndoAct : public OTabFieldUndoAct
120 	{
121 	protected:
122 		virtual void Undo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode(); }
123 		virtual void Redo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); }
124 
125 	public:
126 		OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { }
127 	};
128 
129 	// ================================================================================================
130 	// OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
131 
132 	class OTabFieldCreateUndoAct : public OTabFieldUndoAct
133 	{
134 	protected:
135 		virtual void Undo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();}
136 		virtual void Redo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode();}
137 
138 	public:
139 		OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { }
140 	};
141 
142 	// ================================================================================================
143 	// OTabFieldMovedUndoAct - Undo-class when a field was moved inside the selection
144 
145 	class OTabFieldMovedUndoAct : public OTabFieldUndoAct
146 	{
147 	protected:
148 		virtual void Undo();
149 		virtual void Redo()
150 		{
151 			Undo();
152 		}
153 
154 	public:
155 		OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { }
156 	};
157 }
158 #endif // DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
159 
160 
161 
162